結果

問題 No.1588 Connection
ユーザー ああいいああいい
提出日時 2021-12-08 19:10:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 26,432 KB
平均クエリ数 557.78
最終ジャッジ日時 2023-09-23 08:18:57
合計ジャッジ時間 4,780 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
23,676 KB
testcase_01 AC 42 ms
23,936 KB
testcase_02 AC 42 ms
24,276 KB
testcase_03 AC 42 ms
23,524 KB
testcase_04 AC 41 ms
24,096 KB
testcase_05 AC 43 ms
23,528 KB
testcase_06 AC 44 ms
24,300 KB
testcase_07 AC 41 ms
24,264 KB
testcase_08 AC 45 ms
23,600 KB
testcase_09 AC 44 ms
24,340 KB
testcase_10 AC 45 ms
24,308 KB
testcase_11 AC 47 ms
24,128 KB
testcase_12 AC 88 ms
24,380 KB
testcase_13 AC 90 ms
24,492 KB
testcase_14 AC 42 ms
24,096 KB
testcase_15 AC 43 ms
23,644 KB
testcase_16 AC 42 ms
24,168 KB
testcase_17 AC 42 ms
24,088 KB
testcase_18 AC 41 ms
24,048 KB
testcase_19 AC 42 ms
24,248 KB
testcase_20 AC 48 ms
26,044 KB
testcase_21 AC 156 ms
26,432 KB
testcase_22 AC 155 ms
26,388 KB
testcase_23 AC 83 ms
24,140 KB
testcase_24 AC 65 ms
24,188 KB
testcase_25 AC 101 ms
26,024 KB
testcase_26 AC 99 ms
26,072 KB
testcase_27 AC 67 ms
24,028 KB
testcase_28 AC 59 ms
24,044 KB
testcase_29 AC 156 ms
24,364 KB
testcase_30 AC 157 ms
24,320 KB
testcase_31 AC 40 ms
24,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

B = 'Black'
W = 'White'

q = []
masu = [[0] * (N+1) for _ in range(N+1)]
masu[1][1] = 1

q.append((1,1))
while len(q):
    x,y = q.pop()
    if x == N and y == N:
        print('Yes')
        exit()
        
    for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 1 <= x+i <= N and 1 <= y+j <= N:
            if masu[x+i][y+j] == 0:
                print(x+i,y+j)
                T = input()
                if T == B:
                    masu[x+i][y+j] = 1
                    q.append((x+i,y+j))
                else:
                    masu[x+i][y+j] = -1
print('No')
0