結果

問題 No.1588 Connection
ユーザー ktr216ktr216
提出日時 2021-07-08 22:44:57
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 1,591 ms
使用メモリ 22,608 KB
平均クエリ数 551.19
最終ジャッジ日時 2023-02-15 00:06:03
合計ジャッジ時間 4,873 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 22 ms
22,468 KB
testcase_01 AC 23 ms
22,004 KB
testcase_02 AC 22 ms
22,204 KB
testcase_03 AC 22 ms
22,608 KB
testcase_04 AC 23 ms
21,940 KB
testcase_05 AC 22 ms
21,916 KB
testcase_06 AC 24 ms
21,880 KB
testcase_07 AC 23 ms
22,252 KB
testcase_08 AC 25 ms
22,204 KB
testcase_09 AC 26 ms
21,892 KB
testcase_10 AC 25 ms
21,892 KB
testcase_11 AC 26 ms
21,916 KB
testcase_12 AC 57 ms
21,892 KB
testcase_13 AC 63 ms
21,880 KB
testcase_14 AC 23 ms
21,916 KB
testcase_15 AC 24 ms
21,916 KB
testcase_16 AC 22 ms
21,868 KB
testcase_17 AC 24 ms
21,768 KB
testcase_18 AC 23 ms
21,880 KB
testcase_19 AC 24 ms
21,756 KB
testcase_20 AC 25 ms
21,892 KB
testcase_21 AC 108 ms
22,216 KB
testcase_22 AC 107 ms
21,892 KB
testcase_23 AC 56 ms
22,576 KB
testcase_24 AC 41 ms
21,892 KB
testcase_25 AC 66 ms
22,240 KB
testcase_26 AC 65 ms
21,952 KB
testcase_27 AC 41 ms
21,780 KB
testcase_28 AC 36 ms
22,464 KB
testcase_29 AC 106 ms
22,564 KB
testcase_30 AC 106 ms
22,552 KB
testcase_31 AC 22 ms
22,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
using namespace std;

typedef long long ll;

int main() {
    int N, M, dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    string T;
    cin >> N >> M;
    vector<vector<int>> c(N, vector<int>(N, -1));
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    c[0][0] = 1;
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        int x = p.first, y = p.second;
        rep(i, 0, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx == N - 1 && ny == N - 1) {
                cout << "Yes" << endl;
                return 0;
            }
            if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
            if (c[nx][ny] != -1) continue;
            cout << nx + 1 << " " << ny + 1 << endl;
            cin >> T;
            if (T == "-1") return 0;
            if (T == "Black") {
                c[nx][ny] = 1;
                q.push(make_pair(nx, ny));
            } else {
                c[nx][ny] = 0;
            }
        }        
    }
    cout << "No" << endl;
}
0