結果

問題 No.1588 Connection
ユーザー IgrmiIgrmi
提出日時 2021-07-08 23:30:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 96,424 KB
平均クエリ数 372.84
最終ジャッジ日時 2023-09-24 11:40:52
合計ジャッジ時間 6,166 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
87,464 KB
testcase_01 AC 93 ms
87,592 KB
testcase_02 AC 94 ms
87,316 KB
testcase_03 AC 94 ms
86,672 KB
testcase_04 AC 95 ms
86,972 KB
testcase_05 AC 95 ms
87,328 KB
testcase_06 AC 97 ms
87,400 KB
testcase_07 AC 98 ms
87,024 KB
testcase_08 AC 98 ms
87,464 KB
testcase_09 AC 101 ms
87,044 KB
testcase_10 AC 99 ms
86,892 KB
testcase_11 AC 100 ms
87,408 KB
testcase_12 AC 139 ms
92,984 KB
testcase_13 AC 111 ms
86,984 KB
testcase_14 AC 96 ms
87,388 KB
testcase_15 AC 98 ms
87,180 KB
testcase_16 AC 98 ms
86,752 KB
testcase_17 AC 93 ms
87,316 KB
testcase_18 AC 94 ms
87,356 KB
testcase_19 AC 93 ms
87,632 KB
testcase_20 AC 97 ms
87,500 KB
testcase_21 AC 219 ms
96,124 KB
testcase_22 AC 208 ms
96,160 KB
testcase_23 AC 152 ms
93,324 KB
testcase_24 AC 120 ms
91,564 KB
testcase_25 AC 207 ms
96,424 KB
testcase_26 AC 188 ms
96,080 KB
testcase_27 AC 131 ms
91,116 KB
testcase_28 AC 121 ms
91,120 KB
testcase_29 AC 174 ms
93,408 KB
testcase_30 AC 274 ms
94,408 KB
testcase_31 AC 96 ms
86,888 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