結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-08 23:21:45 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 962 bytes |
| コンパイル時間 | 296 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 85,324 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-07-17 12:32:24 |
| 合計ジャッジ時間 | 4,773 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | AC * 1 RE * 30 |
ソースコード
from collections import deque
N, M = map(int, input().split())
grid = [[None]*N for _ in range(N)]
grid[0][0] = True
grid[-1][-1] = True
M -= 2
q = deque()
q.append((0, 0))
move = [(-1, 0), (1, 0), (0, 1), (0, -1)]
def ques(y, x, cnt):
cnt[0] += 1
print(x+1, y+1)
s = input()
if s == 'Black':
return True
else:
return False
flag = False
cnt = [0]
while q and M:
y, x = q.popleft()
for dy, dx in move:
ny, nx = dy+y, dx+x
if 0 <= ny < N and 0 <= nx < N and grid[ny][nx] is None:
if nx == ny == N-1:
flag = True
q = deque()
break
if ques(ny, nx):
grid[ny][nx] = True
q.append((ny, nx))
M -= 1
else:
grid[ny][nx] = False
if cnt[0] == 3000:
q = deque()
break
if flag:
print('Yes')
else:
print('No')