結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-08 23:23:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 746 bytes |
| コンパイル時間 | 310 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 29,720 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-07-17 12:33:12 |
| 合計ジャッジ時間 | 3,956 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 31 |
ソースコード
from collections import deque
N, M = map(int, input().split())
d = deque([(0, 0)])
table = [[None] * N for _ in range(N)]
table[0][0] = True
def query(x, y):
print(x, y, flush=True)
T = int(input())
if T == 'Black':
return True
elif T == 'White':
return False
else:
raise ValueError
while d:
x, y = d.pop()
if x == N-1 and y == N-1:
print('Yes', flush=True)
exit()
for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
xdx, ydy = x + dx, y + dy
if 0 <= xdx < N and 0 <= ydy < N and table[xdx][ydy] is None:
T = query(xdx, ydy)
table[xdx][ydy] = T
if T:
d.append((xdx + 1, ydy + 1))
print('No', flush=True)