結果

問題 No.1588 Connection
ユーザー KeroruKeroru
提出日時 2021-07-08 23:17:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 95,892 KB
平均クエリ数 442.31
最終ジャッジ日時 2023-09-24 11:35:16
合計ジャッジ時間 6,219 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
86,512 KB
testcase_01 AC 92 ms
87,180 KB
testcase_02 AC 91 ms
86,996 KB
testcase_03 AC 88 ms
86,824 KB
testcase_04 AC 89 ms
87,024 KB
testcase_05 AC 89 ms
87,096 KB
testcase_06 AC 93 ms
87,400 KB
testcase_07 AC 88 ms
87,268 KB
testcase_08 AC 99 ms
87,164 KB
testcase_09 AC 101 ms
86,924 KB
testcase_10 AC 101 ms
87,180 KB
testcase_11 AC 101 ms
87,132 KB
testcase_12 AC 153 ms
92,416 KB
testcase_13 AC 130 ms
91,880 KB
testcase_14 AC 94 ms
86,636 KB
testcase_15 AC 98 ms
87,104 KB
testcase_16 AC 95 ms
87,360 KB
testcase_17 AC 94 ms
87,160 KB
testcase_18 AC 93 ms
86,832 KB
testcase_19 AC 93 ms
86,620 KB
testcase_20 AC 94 ms
87,196 KB
testcase_21 AC 229 ms
95,892 KB
testcase_22 AC 221 ms
94,992 KB
testcase_23 AC 156 ms
91,796 KB
testcase_24 AC 126 ms
90,488 KB
testcase_25 AC 202 ms
95,584 KB
testcase_26 AC 201 ms
95,472 KB
testcase_27 AC 138 ms
91,652 KB
testcase_28 AC 123 ms
91,528 KB
testcase_29 AC 178 ms
93,584 KB
testcase_30 AC 233 ms
93,664 KB
testcase_31 AC 90 ms
87,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0