結果

問題 No.1588 Connection
ユーザー rlangevinrlangevin
提出日時 2024-04-29 00:03:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 96,216 KB
平均クエリ数 563.00
最終ジャッジ日時 2024-04-29 00:03:21
合計ジャッジ時間 5,841 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,616 KB
testcase_01 AC 66 ms
70,368 KB
testcase_02 AC 68 ms
69,984 KB
testcase_03 AC 70 ms
70,880 KB
testcase_04 AC 68 ms
70,368 KB
testcase_05 AC 76 ms
70,880 KB
testcase_06 AC 70 ms
70,496 KB
testcase_07 AC 67 ms
70,624 KB
testcase_08 AC 71 ms
71,008 KB
testcase_09 AC 72 ms
71,520 KB
testcase_10 AC 74 ms
71,520 KB
testcase_11 AC 88 ms
71,512 KB
testcase_12 AC 159 ms
94,040 KB
testcase_13 AC 170 ms
93,724 KB
testcase_14 AC 68 ms
69,984 KB
testcase_15 AC 69 ms
71,160 KB
testcase_16 AC 67 ms
70,368 KB
testcase_17 AC 71 ms
69,984 KB
testcase_18 AC 68 ms
70,496 KB
testcase_19 AC 65 ms
70,624 KB
testcase_20 AC 71 ms
71,776 KB
testcase_21 AC 275 ms
96,004 KB
testcase_22 AC 244 ms
96,216 KB
testcase_23 AC 158 ms
93,636 KB
testcase_24 AC 112 ms
82,420 KB
testcase_25 AC 184 ms
95,320 KB
testcase_26 AC 176 ms
95,584 KB
testcase_27 AC 123 ms
80,608 KB
testcase_28 AC 92 ms
78,176 KB
testcase_29 AC 258 ms
93,152 KB
testcase_30 AC 237 ms
93,888 KB
testcase_31 AC 65 ms
70,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N, M = map(int, input().split())
Q = deque()
Q.append((0, 0))
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
seen = [[0] * N for _ in range(N)]
seen[0][0] = 1

def query(x, y):
    print(x+1, y+1, flush=True)
    return input() == "Black"

while Q:
    px, py = Q.popleft()
    for k in range(4):
        x = px + dx[k]
        y = py + dy[k]
        if x < 0 or x > N - 1 or y < 0 or y > N - 1:
            continue
        if seen[x][y]:
            continue
        seen[x][y] = 1
        if query(x, y):
            Q.append((x, y))
            
print("Yes") if seen[N-1][N-1] else print("No")
0