結果

問題 No.1588 Connection
ユーザー ShibuyapShibuyap
提出日時 2021-07-08 22:44:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,516 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 205,356 KB
実行使用メモリ 24,408 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-09-24 10:47:46
合計ジャッジ時間 5,241 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
23,556 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 27 ms
24,348 KB
testcase_10 AC 27 ms
23,376 KB
testcase_11 AC 28 ms
23,544 KB
testcase_12 AC 56 ms
23,664 KB
testcase_13 AC 64 ms
23,688 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 108 ms
23,844 KB
testcase_22 AC 107 ms
23,808 KB
testcase_23 AC 58 ms
24,336 KB
testcase_24 AC 44 ms
23,532 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 107 ms
24,348 KB
testcase_30 AC 108 ms
24,336 KB
testcase_31 AC 25 ms
23,412 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 (a[n][n]) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}
0