結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
navel_tos
|
| 提出日時 | 2024-02-01 01:08:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 549 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 82,016 KB |
| 平均クエリ数 | 1.00 |
| 最終ジャッジ日時 | 2024-09-28 10:25:57 |
| 合計ジャッジ時間 | 5,635 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 31 |
ソースコード
import deque
N,M = map(int,input().split())
#-1: 白確定 0: 不明 1: 黒確定
G = [[0] * (N+1) for _ in range(N+1)]
for h in range(N+1):
G[h][0] = -1
G[0][h] = -1
G[1][1] = 1
M -= 2
Q = deque([(1,2),(2,1)])
while Q:
h,w = Q.popleft()
if G[h][w] != 0: continue
if h == w == N:
print('Yes')
exit()
if M == 0: continue
M -= 1
print(h,w)
a = input()
G[h][w] = -1 if a == 'White' else 1
for x,y in[(h-1,w),(h+1,w),(h,w-1),(h,w+1)]:
if x in range(1, N+1) and y in range(1, N+1):
Q.append((x,y))
print('No')
navel_tos