結果

問題 No.1588 Connection
コンテスト
ユーザー 回転
提出日時 2025-11-14 16:50:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 98,368 KB
平均クエリ数 1636.69
最終ジャッジ日時 2025-11-14 16:50:21
合計ジャッジ時間 8,020 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 10 RE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque
N,M = list(map(int,input().split()))

dy = [-1,1,0,0]
dx = [0,0,-1,1]

q = deque([(0,0)])
grid = [[-1 for _ in range(N)] for _ in range(N)]
while(q):
    y,x = q.popleft()

    if(y == N-1 and x == N-1):
        print("Yes")
        exit()

    if(grid[y][x] != -1):continue
    if not (y == 0 and x == 0):
        print(y+1,x+1)
        bw = input()
        grid[y][x] = 1 if bw == "Black" else 0

    for i in range(4):
        next_y = y + dy[i]
        next_x = x + dx[i]
        if(next_y < 0 or N <= next_y):continue
        if(next_x < 0 or N <= next_x):continue
        if(grid[next_y][next_x] == 0):continue
        q.append((next_y,next_x))
    
print("No")
0