提出 #74860638


ソースコード 拡げる

// Date: 2026-04-11
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
    bool debug_mode = 1;
#else
    bool debug_mode = 0;
#endif

using ll = long long;
#define cerr if(debug_mode) cerr

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    int h, w; cin >> h >> w;

    vector<string> mp(h); for (auto &s : mp) cin >> s;

    int moveStk[5000005] = {};
    int back_iterator = 0;
    vector<vector<array<bool, 5>>> visi(h, vector<array<bool, 5>>(w));

    const int dx[] = {0, 0, -1, 1};
    const int dy[] = {-1, 1, 0, 0};
    const string trans = "LRUD";

    auto valid = [&](int x, int y) -> bool {
        return x >= 0 && x < h && y >= 0 && y < w && mp[x][y] != '#';
    };

    auto dfs = [&](auto self, int x, int y, int dir) -> void {
        if (!valid(x, y)) return;
        if (visi[x][y][dir]) return;

        if (mp[x][y] == 'G') {
            cout << "Yes\n";
            for (int i = 0; i < back_iterator; i++) cout << trans[moveStk[i]];
            exit(0);
        }

        //cout << x << ' ' << y << '\n';

        visi[x][y][dir] = 1;

        for (int d = 0; d < 4; d++) {
            if (mp[x][y] == 'o' && d != dir) continue;
            if (mp[x][y] == 'x' && d == dir) continue;

            moveStk[back_iterator++] = d;
            self(self, x + dx[d], y + dy[d], d);
            back_iterator--;
        }
    };

    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (mp[i][j] == 'S') dfs(dfs, i, j, 4);
    }

    cout << "No";
}

提出情報

提出日時
問題 D - Go Straight
ユーザ Emmetthor
言語 C++ IOI-Style(GNU++20) (GCC 14.2.0)
得点 425
コード長 1563 Byte
結果 AC
実行時間 390 ms
メモリ 654032 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 3
AC × 46
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 10 ms 21288 KiB
example_01.txt AC 10 ms 21288 KiB
example_02.txt AC 10 ms 21288 KiB
hand_00.txt AC 315 ms 497696 KiB
hand_01.txt AC 13 ms 27432 KiB
hand_02.txt AC 355 ms 654032 KiB
hand_03.txt AC 347 ms 652572 KiB
hand_04.txt AC 9 ms 21288 KiB
hand_05.txt AC 368 ms 494504 KiB
hand_06.txt AC 179 ms 339056 KiB
hand_07.txt AC 390 ms 495528 KiB
hand_08.txt AC 14 ms 27304 KiB
hand_09.txt AC 10 ms 21288 KiB
random_00.txt AC 12 ms 27048 KiB
random_01.txt AC 49 ms 55976 KiB
random_02.txt AC 87 ms 75688 KiB
random_03.txt AC 14 ms 26920 KiB
random_04.txt AC 54 ms 61864 KiB
random_05.txt AC 76 ms 41000 KiB
random_06.txt AC 14 ms 27048 KiB
random_07.txt AC 13 ms 26920 KiB
random_08.txt AC 16 ms 28840 KiB
random_09.txt AC 70 ms 43560 KiB
random_10.txt AC 32 ms 37928 KiB
random_11.txt AC 53 ms 43304 KiB
random_12.txt AC 62 ms 40104 KiB
random_13.txt AC 13 ms 26536 KiB
random_14.txt AC 31 ms 31912 KiB
random_15.txt AC 13 ms 26664 KiB
random_16.txt AC 13 ms 26792 KiB
random_17.txt AC 13 ms 26408 KiB
random_18.txt AC 13 ms 26536 KiB
random_19.txt AC 13 ms 27432 KiB
random_20.txt AC 13 ms 26536 KiB
random_21.txt AC 16 ms 32296 KiB
random_22.txt AC 13 ms 26536 KiB
random_23.txt AC 13 ms 27432 KiB
random_24.txt AC 14 ms 29992 KiB
random_25.txt AC 13 ms 28200 KiB
random_26.txt AC 12 ms 26664 KiB
random_27.txt AC 72 ms 129064 KiB
random_28.txt AC 13 ms 26792 KiB
random_29.txt AC 14 ms 29992 KiB
random_30.txt AC 17 ms 32424 KiB
random_31.txt AC 22 ms 40616 KiB
random_32.txt AC 16 ms 29224 KiB