結果

問題 No.1588 Connection
ユーザー ntudantuda
提出日時 2021-07-24 09:25:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 96,432 KB
平均クエリ数 343.94
最終ジャッジ日時 2023-09-26 15:08:57
合計ジャッジ時間 7,334 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
87,464 KB
testcase_01 AC 90 ms
87,220 KB
testcase_02 AC 90 ms
87,360 KB
testcase_03 AC 91 ms
87,400 KB
testcase_04 AC 90 ms
87,256 KB
testcase_05 AC 90 ms
86,992 KB
testcase_06 AC 91 ms
86,800 KB
testcase_07 AC 89 ms
87,560 KB
testcase_08 AC 92 ms
86,928 KB
testcase_09 AC 92 ms
87,084 KB
testcase_10 AC 91 ms
87,116 KB
testcase_11 AC 92 ms
87,048 KB
testcase_12 AC 94 ms
87,200 KB
testcase_13 AC 95 ms
87,108 KB
testcase_14 AC 89 ms
87,584 KB
testcase_15 AC 89 ms
87,220 KB
testcase_16 AC 90 ms
86,952 KB
testcase_17 AC 90 ms
86,880 KB
testcase_18 AC 91 ms
86,828 KB
testcase_19 AC 90 ms
87,288 KB
testcase_20 AC 92 ms
87,220 KB
testcase_21 AC 188 ms
96,432 KB
testcase_22 AC 190 ms
96,288 KB
testcase_23 AC 129 ms
92,788 KB
testcase_24 AC 111 ms
91,692 KB
testcase_25 AC 189 ms
95,976 KB
testcase_26 AC 185 ms
96,196 KB
testcase_27 AC 122 ms
91,372 KB
testcase_28 AC 114 ms
91,656 KB
testcase_29 AC 180 ms
94,396 KB
testcase_30 AC 226 ms
94,412 KB
testcase_31 AC 88 ms
87,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(2000)
N,M = map(int,input().split())
S0 = [[1] * (N+2)]
S = S0 + [([1] + [0] * N + [1]) for _ in range(N)] + S0
D = [[0,1],[1,0],[0,-1],[-1,0]]

def dfs(x,y):
    if x == N and y == N:
        print("Yes")
        sys.exit()
    for d in D:
        a,b = d
        x1 = x + a
        y1 = y + b
        if S[x1][y1] == 0:
            S[x1][y1] = 1
            print(x1,y1)
            res = input()
            if res == "-1":
                sys.exit()
            elif res == "Black":
                dfs(x1,y1)
    
    
S[1][1] = 1
dfs(1,1)
print("No")
sys.exit()
0