結果

問題 No.1588 Connection
ユーザー titiatitia
提出日時 2021-07-08 23:06:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 409 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 26,592 KB
平均クエリ数 562.31
最終ジャッジ日時 2023-09-24 11:30:53
合計ジャッジ時間 4,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
23,784 KB
testcase_01 AC 40 ms
24,060 KB
testcase_02 AC 40 ms
24,324 KB
testcase_03 AC 41 ms
23,532 KB
testcase_04 AC 40 ms
23,712 KB
testcase_05 AC 39 ms
24,048 KB
testcase_06 AC 41 ms
23,412 KB
testcase_07 AC 40 ms
23,504 KB
testcase_08 AC 43 ms
24,072 KB
testcase_09 AC 43 ms
24,048 KB
testcase_10 AC 45 ms
24,168 KB
testcase_11 AC 44 ms
23,484 KB
testcase_12 AC 85 ms
23,676 KB
testcase_13 AC 92 ms
24,360 KB
testcase_14 AC 41 ms
23,736 KB
testcase_15 AC 42 ms
23,660 KB
testcase_16 AC 40 ms
24,072 KB
testcase_17 AC 40 ms
24,240 KB
testcase_18 AC 40 ms
24,072 KB
testcase_19 AC 43 ms
24,420 KB
testcase_20 AC 46 ms
25,928 KB
testcase_21 AC 150 ms
26,044 KB
testcase_22 AC 150 ms
25,992 KB
testcase_23 AC 84 ms
24,636 KB
testcase_24 AC 64 ms
24,180 KB
testcase_25 AC 100 ms
25,824 KB
testcase_26 AC 97 ms
26,592 KB
testcase_27 AC 63 ms
24,120 KB
testcase_28 AC 57 ms
24,344 KB
testcase_29 AC 152 ms
23,716 KB
testcase_30 AC 155 ms
24,436 KB
testcase_31 AC 40 ms
23,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())

MAP=[[-1]*N for i in range(N)]

MAP[0][0]=1
MAP[N-1][N-1]=1

Q=[(0,0)]

c=0

while Q:
    x,y=Q.pop()
    if c==3000:
        break

    for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
        if 0<=z<N and 0<=w<N and MAP[z][w]==-1:
            print(z+1,w+1,flush=True)
            c+=1
            a=input()

            if a[0]=="B":
                MAP[z][w]=1
                Q.append((z,w))
            else:
                MAP[z][w]=0

        if c==3000:
            break

if MAP[N-2][N-1]==1 or MAP[N-1][N-2]==1:
    print("Yes",flush=True)
else:
    print("No",flush=True)
0