結果

問題 No.1588 Connection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-14 23:29:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 96,396 KB
平均クエリ数 472.03
最終ジャッジ日時 2023-09-24 12:10:19
合計ジャッジ時間 7,511 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
87,944 KB
testcase_01 AC 127 ms
87,948 KB
testcase_02 AC 123 ms
87,516 KB
testcase_03 AC 122 ms
87,748 KB
testcase_04 AC 124 ms
87,360 KB
testcase_05 AC 124 ms
87,756 KB
testcase_06 AC 126 ms
87,836 KB
testcase_07 AC 124 ms
87,240 KB
testcase_08 AC 129 ms
87,280 KB
testcase_09 AC 130 ms
87,312 KB
testcase_10 AC 131 ms
87,460 KB
testcase_11 AC 132 ms
87,396 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 123 ms
88,256 KB
testcase_15 AC 125 ms
87,212 KB
testcase_16 AC 122 ms
87,852 KB
testcase_17 AC 124 ms
87,796 KB
testcase_18 AC 124 ms
87,936 KB
testcase_19 AC 125 ms
87,616 KB
testcase_20 AC 130 ms
89,092 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 204 ms
94,332 KB
testcase_24 AC 167 ms
93,088 KB
testcase_25 AC 225 ms
95,096 KB
testcase_26 AC 228 ms
94,308 KB
testcase_27 AC 162 ms
92,584 KB
testcase_28 AC 152 ms
92,164 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 123 ms
87,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

n,m = map(int,input().split())
count = 0

black = [[-1]*n for i in range(n)]
black[0][0] = black[-1][-1] = 1
q = deque([(0,0)])
while q and count < 3000:
    x,y = q.popleft()
    for dx,dy in ((0,1),(1,0),(0,-1),(-1,0)):
        nx = x+dx
        ny = y+dy
        if nx == ny == n-1:
            print("Yes")
            exit()
        if 0 <= nx < n and 0 <= ny < n and black[nx][ny] == -1:
            print(nx+1,ny+1)
            sys.stdout.flush()
            s = input()
            if s == "Black":
                black[nx][ny] = 1
                q.append((nx,ny))
            else:
                black[nx][ny] = 0
        count += 1
print("No")
0