結果

問題 No.1588 Connection
ユーザー vwxyzvwxyz
提出日時 2023-12-21 10:00:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 28,032 KB
平均クエリ数 543.84
最終ジャッジ日時 2023-12-21 10:00:35
合計ジャッジ時間 4,437 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
26,112 KB
testcase_01 AC 49 ms
26,112 KB
testcase_02 AC 46 ms
26,112 KB
testcase_03 AC 50 ms
26,112 KB
testcase_04 AC 46 ms
26,112 KB
testcase_05 AC 46 ms
26,112 KB
testcase_06 AC 47 ms
26,112 KB
testcase_07 AC 46 ms
26,112 KB
testcase_08 AC 48 ms
26,112 KB
testcase_09 AC 49 ms
26,112 KB
testcase_10 AC 50 ms
26,112 KB
testcase_11 AC 50 ms
26,112 KB
testcase_12 AC 83 ms
26,112 KB
testcase_13 AC 92 ms
26,112 KB
testcase_14 AC 47 ms
26,112 KB
testcase_15 AC 49 ms
26,112 KB
testcase_16 AC 48 ms
26,112 KB
testcase_17 AC 46 ms
26,112 KB
testcase_18 AC 46 ms
26,112 KB
testcase_19 AC 47 ms
26,368 KB
testcase_20 AC 53 ms
28,032 KB
testcase_21 AC 158 ms
28,032 KB
testcase_22 AC 162 ms
28,032 KB
testcase_23 AC 88 ms
26,368 KB
testcase_24 AC 67 ms
26,112 KB
testcase_25 AC 102 ms
28,032 KB
testcase_26 AC 99 ms
28,032 KB
testcase_27 AC 68 ms
26,368 KB
testcase_28 AC 61 ms
26,112 KB
testcase_29 AC 148 ms
26,112 KB
testcase_30 AC 149 ms
26,112 KB
testcase_31 AC 50 ms
26,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
queue=[(0,0)]
seen=[[False]*N for x in range(N)]
seen[0][0]=True
while queue:
    x,y=queue.pop()
    for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)):
        xx=x+dx
        yy=y+dy
        if (xx,yy)==(N-1,N-1):
            print("Yes")
            exit()
        if 0<=xx<N and 0<=yy<N and not seen[xx][yy]:
            print(xx+1,yy+1)
            S=input()
            if S=="Black":
                queue.append((xx,yy))
            seen[xx][yy]=True
print("No")
0