結果
問題 | No.1588 Connection |
ユーザー | Keroru |
提出日時 | 2021-07-08 23:17:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 217 ms / 2,000 ms |
コード長 | 593 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 95,264 KB |
平均クエリ数 | 442.31 |
最終ジャッジ日時 | 2024-07-17 12:30:03 |
合計ジャッジ時間 | 5,015 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 31 |
ソースコード
n,m=map(int,input().split()) q=[(1,2),(2,1)] p=[[0]*(n+1)for i in range(n+1)] p[1][1]=1 c=0 while q: a,b=q.pop() if (a,b)==(n,n): print('Yes',flush=True) exit() #show((a,b),q,p) print(a,b,flush=True) c+=1 if input()=='Black': p[a][b]=1 for u,v in [(-1,0),(1,0),(0,1),(0,-1)]: if 1<=a+u<=n and 1<=b+v<=n and p[a+u][b+v]==0: q+=(a+u,b+v), p[a+u][b+v]==-2 else: p[a][b]=-1 if c==3000: break if (n,n)in q: print('Yes',flush=True) exit() print('No',flush=True)