結果

問題 No.1588 Connection
ユーザー IgrmiIgrmi
提出日時 2021-07-08 23:30:20
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 253 ms
使用メモリ 100,616 KB
平均クエリ数 372.84
最終ジャッジ日時 2023-02-15 01:14:57
合計ジャッジ時間 6,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 90 ms
90,380 KB
testcase_01 AC 90 ms
90,448 KB
testcase_02 AC 90 ms
90,348 KB
testcase_03 AC 91 ms
90,788 KB
testcase_04 AC 91 ms
90,392 KB
testcase_05 AC 89 ms
90,104 KB
testcase_06 AC 92 ms
90,620 KB
testcase_07 AC 90 ms
90,492 KB
testcase_08 AC 95 ms
90,360 KB
testcase_09 AC 94 ms
90,312 KB
testcase_10 AC 94 ms
90,392 KB
testcase_11 AC 95 ms
90,032 KB
testcase_12 AC 142 ms
97,160 KB
testcase_13 AC 108 ms
90,880 KB
testcase_14 AC 90 ms
90,312 KB
testcase_15 AC 91 ms
90,216 KB
testcase_16 AC 90 ms
90,252 KB
testcase_17 AC 89 ms
90,376 KB
testcase_18 AC 90 ms
90,248 KB
testcase_19 AC 91 ms
90,312 KB
testcase_20 AC 93 ms
90,264 KB
testcase_21 AC 233 ms
99,408 KB
testcase_22 AC 240 ms
100,252 KB
testcase_23 AC 155 ms
96,960 KB
testcase_24 AC 124 ms
95,300 KB
testcase_25 AC 229 ms
100,616 KB
testcase_26 AC 225 ms
100,588 KB
testcase_27 AC 137 ms
96,048 KB
testcase_28 AC 125 ms
95,772 KB
testcase_29 AC 194 ms
97,392 KB
testcase_30 AC 248 ms
97,536 KB
testcase_31 AC 90 ms
90,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
D = [(-1, 0), (1, 0), (0, -1), (0, 1)]
Grid = [[0] * (N + 1) for _ in range(N + 1)]
Grid[1][1] = 1
Query = [(1, 1)]
while Query:
    H, W = Query.pop()
    print(H, W)
    Judge = input()
    if Judge == 'Black':
        for d1, d2 in D:
            h, w = H + d1, W + d2
            if h == N and w == N:
                print('Yes')
                exit()
            if h >= 1 and h <= N and w >= 1 and w <= N and not Grid[h][w]:
                Query.append((h, w))
                Grid[h][w] = 1
    elif Judge == '-1': exit()
print('No')
0