結果

問題 No.1588 Connection
ユーザー merom686merom686
提出日時 2021-07-08 22:46:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,235 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 206,360 KB
実行使用メモリ 24,396 KB
平均クエリ数 425.50
最終ジャッジ日時 2023-09-24 10:48:31
合計ジャッジ時間 4,929 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,372 KB
testcase_01 AC 23 ms
23,604 KB
testcase_02 AC 23 ms
23,844 KB
testcase_03 AC 23 ms
23,616 KB
testcase_04 AC 23 ms
23,412 KB
testcase_05 AC 24 ms
23,604 KB
testcase_06 AC 23 ms
23,604 KB
testcase_07 AC 24 ms
23,376 KB
testcase_08 AC 25 ms
23,616 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 27 ms
23,352 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 25 ms
23,616 KB
testcase_15 AC 25 ms
23,616 KB
testcase_16 AC 25 ms
24,012 KB
testcase_17 AC 25 ms
23,388 KB
testcase_18 AC 25 ms
23,832 KB
testcase_19 AC 26 ms
24,384 KB
testcase_20 AC 27 ms
23,580 KB
testcase_21 AC 103 ms
23,616 KB
testcase_22 AC 103 ms
23,388 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 66 ms
24,396 KB
testcase_26 AC 62 ms
23,616 KB
testcase_27 AC 41 ms
23,580 KB
testcase_28 AC 26 ms
23,496 KB
testcase_29 AC 99 ms
24,324 KB
testcase_30 AC 99 ms
23,520 KB
testcase_31 AC 24 ms
23,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int a[502][502];

int main() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i <= n + 1; i++) {
        for (int j = 0; j <= n + 1; j++) {
            a[i][j] = -1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            a[i][j] = 0;
        }
    }

    a[1][1] = 1;
    a[n][n] = 1;

    queue<pair<int, int>> q;
    q.push({ 1, 1 });

    while (!q.empty()) {
        auto p = q.back(); q.pop();
        pair<int, int> d[4] = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
        for (int k = 0; k < 4; k++) {
            auto t = p;
            t.first += d[k].first;
            t.second += d[k].second;
            if (t.first == n && t.second == n) {
                cout << "Yes" << endl;
                exit(0);
            }
            int x = a[t.first][t.second];
            if (x != 0) continue;
            cout << t.first << ' ' << t.second << endl;
            string s;
            cin >> s;
            a[t.first][t.second] = s[0] == 'B' ? 1 : 2;
            if (a[t.first][t.second] == 1) {
                q.push(t);
            }
        }
    }
    cout << "No" << endl;

    return 0;
}
0