結果

問題 No.1588 Connection
ユーザー ShibuyapShibuyap
提出日時 2021-07-08 22:46:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,545 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 206,188 KB
実行使用メモリ 24,396 KB
平均クエリ数 551.78
最終ジャッジ日時 2023-09-24 10:48:48
合計ジャッジ時間 4,957 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,652 KB
testcase_01 AC 23 ms
24,048 KB
testcase_02 AC 23 ms
24,336 KB
testcase_03 AC 23 ms
24,048 KB
testcase_04 AC 24 ms
23,388 KB
testcase_05 AC 24 ms
23,856 KB
testcase_06 AC 25 ms
24,372 KB
testcase_07 AC 23 ms
24,396 KB
testcase_08 AC 26 ms
24,276 KB
testcase_09 AC 28 ms
24,348 KB
testcase_10 AC 26 ms
23,520 KB
testcase_11 AC 27 ms
23,856 KB
testcase_12 AC 55 ms
23,388 KB
testcase_13 AC 61 ms
23,376 KB
testcase_14 AC 23 ms
23,832 KB
testcase_15 AC 24 ms
23,388 KB
testcase_16 AC 24 ms
24,372 KB
testcase_17 AC 24 ms
24,072 KB
testcase_18 AC 23 ms
23,388 KB
testcase_19 AC 23 ms
23,628 KB
testcase_20 AC 26 ms
23,436 KB
testcase_21 AC 101 ms
23,424 KB
testcase_22 AC 100 ms
23,376 KB
testcase_23 AC 55 ms
24,264 KB
testcase_24 AC 41 ms
24,024 KB
testcase_25 AC 66 ms
24,276 KB
testcase_26 AC 64 ms
23,604 KB
testcase_27 AC 42 ms
23,856 KB
testcase_28 AC 37 ms
23,844 KB
testcase_29 AC 96 ms
23,532 KB
testcase_30 AC 98 ms
24,060 KB
testcase_31 AC 22 ms
23,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define MAX_N 200005
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
int main() {
    int n, m;
    cin >> n >> m;
    int a[n + 2][n + 2];
    rep(i, n + 2) rep(j, n + 2) a[i][j] = 0;
    a[1][1]                             = 1;
    a[n][n]                             = 1;

    int f[n + 2][n + 2];
    rep(i, n + 2) {
        rep(j, n + 2) {
            if (i == 0 || j == 0 || i == n + 1 || j == n + 1) f[i][j] = 1;
            else
                f[i][j] = 0;
        }
    }

    f[1][1] = 1;

    queue<P> que;
    que.push(P(1, 1));
    int cnt = 0;
    while (que.size()) {
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        rep(i, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (f[nx][ny]) continue;
            f[nx][ny] = 1;
            cout << nx << ' ' << ny << endl;
            fflush(stdout);
            string s;
            cin >> s;
            cnt++;
            if (s[0] == 'B') {
                a[nx][ny] = 1;
                que.push(P(nx, ny));
            }
            if (cnt == 3000) break;
        }
        if (cnt == 3000) break;
        if (f[n][n]) break;
    }

    if (f[n][n]) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}
0