結果

問題 No.1588 Connection
ユーザー titiatitia
提出日時 2021-07-08 23:06:43
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 61 ms
使用メモリ 24,840 KB
平均クエリ数 562.31
最終ジャッジ日時 2023-02-15 01:01:56
合計ジャッジ時間 4,008 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 32 ms
22,940 KB
testcase_01 AC 32 ms
22,640 KB
testcase_02 AC 32 ms
22,608 KB
testcase_03 AC 32 ms
22,844 KB
testcase_04 AC 34 ms
22,460 KB
testcase_05 AC 32 ms
22,424 KB
testcase_06 AC 34 ms
22,420 KB
testcase_07 AC 32 ms
23,040 KB
testcase_08 AC 34 ms
22,824 KB
testcase_09 AC 37 ms
22,480 KB
testcase_10 AC 37 ms
22,500 KB
testcase_11 AC 39 ms
23,124 KB
testcase_12 AC 78 ms
22,272 KB
testcase_13 AC 84 ms
22,804 KB
testcase_14 AC 32 ms
22,244 KB
testcase_15 AC 34 ms
22,200 KB
testcase_16 AC 32 ms
22,200 KB
testcase_17 AC 33 ms
22,280 KB
testcase_18 AC 33 ms
22,360 KB
testcase_19 AC 33 ms
22,876 KB
testcase_20 AC 38 ms
24,760 KB
testcase_21 AC 139 ms
24,508 KB
testcase_22 AC 140 ms
24,544 KB
testcase_23 AC 74 ms
22,628 KB
testcase_24 AC 56 ms
22,344 KB
testcase_25 AC 90 ms
24,840 KB
testcase_26 AC 88 ms
24,580 KB
testcase_27 AC 55 ms
22,896 KB
testcase_28 AC 49 ms
22,512 KB
testcase_29 AC 143 ms
22,332 KB
testcase_30 AC 144 ms
22,844 KB
testcase_31 AC 33 ms
22,580 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