結果

問題 No.1588 Connection
ユーザー KeroruKeroru
提出日時 2021-07-08 23:17:49
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 296 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 371 ms
使用メモリ 102,188 KB
平均クエリ数 442.31
最終ジャッジ日時 2023-02-15 01:08:10
合計ジャッジ時間 6,573 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 92 ms
90,644 KB
testcase_01 AC 89 ms
90,024 KB
testcase_02 AC 91 ms
90,352 KB
testcase_03 AC 91 ms
90,276 KB
testcase_04 AC 93 ms
90,112 KB
testcase_05 AC 93 ms
90,308 KB
testcase_06 AC 94 ms
90,748 KB
testcase_07 AC 92 ms
90,636 KB
testcase_08 AC 100 ms
90,204 KB
testcase_09 AC 101 ms
90,784 KB
testcase_10 AC 98 ms
90,612 KB
testcase_11 AC 99 ms
90,344 KB
testcase_12 AC 182 ms
96,896 KB
testcase_13 AC 143 ms
95,468 KB
testcase_14 AC 90 ms
90,796 KB
testcase_15 AC 96 ms
90,404 KB
testcase_16 AC 92 ms
90,028 KB
testcase_17 AC 94 ms
90,340 KB
testcase_18 AC 93 ms
90,248 KB
testcase_19 AC 93 ms
90,976 KB
testcase_20 AC 93 ms
90,340 KB
testcase_21 AC 296 ms
102,188 KB
testcase_22 AC 285 ms
99,736 KB
testcase_23 AC 188 ms
97,444 KB
testcase_24 AC 136 ms
95,456 KB
testcase_25 AC 237 ms
99,948 KB
testcase_26 AC 209 ms
99,664 KB
testcase_27 AC 149 ms
95,704 KB
testcase_28 AC 136 ms
95,904 KB
testcase_29 AC 212 ms
98,812 KB
testcase_30 AC 262 ms
97,848 KB
testcase_31 AC 89 ms
90,728 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