結果

問題 No.1588 Connection
コンテスト
ユーザー vwxyz
提出日時 2023-12-21 10:00:30
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 265 ms / 2,000 ms
+ 999µs
コード長 490 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 189 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 12,160 KB
平均クエリ数 617.91
最終ジャッジ日時 2026-10-31 23:17:25
合計ジャッジ時間 3,935 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M=map(int,input().split())
queue=[(0,0)]
seen=[[False]*N for x in range(N)]
seen[0][0]=True
while queue:
    x,y=queue.pop()
    for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)):
        xx=x+dx
        yy=y+dy
        if (xx,yy)==(N-1,N-1):
            print("Yes")
            exit()
        if 0<=xx<N and 0<=yy<N and not seen[xx][yy]:
            print(xx+1,yy+1)
            S=input()
            if S=="Black":
                queue.append((xx,yy))
            seen[xx][yy]=True
print("No")
0