提出 #56030747


ソースコード 拡げる

#include <iostream>
#include <string>
#include <vector>

int main() {
    int H, W, current_i, current_j, target_i, target_j;
    std::string row;
    std::vector<std::string> grid;
    std::string X;

    std::cin >> H >> W >> current_i >> current_j;

    for (int i = 0; i < H; ++i) {
        std::cin >> row;
        grid.push_back(row);
    }
    
    std::cin >> X;

    for (auto c : X) {
        target_i = current_i;
        target_j = current_j;
        
        switch (c) {
            case 'L':
                target_j -= 1;
                break;
            case 'R':
                target_j += 1;
                break;
            case 'U':
                target_i -= 1;
                break;
            case 'D':
                target_i += 1;
                break;
        }

        if (!(1 <= target_i and target_i <= H and 1 <= target_j and target_j <= W)) {
            continue;
        }

        if (grid[target_i-1][target_j-1] == '#') {
            continue;
        }

        current_i = target_i;
        current_j = target_j;
    }

    std::cout << current_i << ' ' << current_j << std::endl;

    return 0;
}

提出情報

提出日時
問題 B - Grid Walk
ユーザ sglre6355
言語 C++ 20 (gcc 12.2)
得点 200
コード長 1202 Byte
結果 AC
実行時間 1 ms
メモリ 3612 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 21
セット名 テストケース
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt
ケース名 結果 実行時間 メモリ
sample00.txt AC 1 ms 3444 KiB
sample01.txt AC 1 ms 3528 KiB
sample02.txt AC 1 ms 3444 KiB
testcase00.txt AC 1 ms 3484 KiB
testcase01.txt AC 1 ms 3524 KiB
testcase02.txt AC 1 ms 3604 KiB
testcase03.txt AC 1 ms 3612 KiB
testcase04.txt AC 1 ms 3416 KiB
testcase05.txt AC 1 ms 3556 KiB
testcase06.txt AC 1 ms 3488 KiB
testcase07.txt AC 1 ms 3540 KiB
testcase08.txt AC 1 ms 3608 KiB
testcase09.txt AC 1 ms 3476 KiB
testcase10.txt AC 1 ms 3544 KiB
testcase11.txt AC 1 ms 3540 KiB
testcase12.txt AC 1 ms 3536 KiB
testcase13.txt AC 1 ms 3476 KiB
testcase14.txt AC 1 ms 3480 KiB
testcase15.txt AC 1 ms 3532 KiB
testcase16.txt AC 1 ms 3488 KiB
testcase17.txt AC 1 ms 3544 KiB