結果

問題 No.1588 Connection
ユーザー aaaaaaaaaa2230
提出日時 2021-07-14 23:01:39
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 655 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 96,764 KB
平均クエリ数 1057.38
最終ジャッジ日時 2024-07-17 13:03:35
合計ジャッジ時間 7,146 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

n,m = map(int,input().split())
count = 0
q = deque([(1,0),(0,1)])
black = [[-1]*n for i in range(n)]
black[0][0] = black[-1][-1] = 1

while q or count < 3000:
    x,y = q.popleft()
    print(x+1,y+1)
    sys.stdin.flush()
    if input() == "Black":
        black[x][y] = 1
        for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)):
            nx = x+dx
            ny = y+dy
            if nx == ny == n-1:
                print("Yes")
                exit()
            if 0 <= nx < n and 0 <= ny < n and black[nx][ny] == -1:
                q.append((nx,ny))
    else:
        black[x][y] = 0
    count += 1
print("No")
0