結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
87,920 KB
testcase_01 AC 124 ms
87,812 KB
testcase_02 AC 124 ms
87,668 KB
testcase_03 AC 123 ms
87,452 KB
testcase_04 AC 125 ms
87,544 KB
testcase_05 AC 122 ms
88,076 KB
testcase_06 AC 127 ms
88,080 KB
testcase_07 AC 125 ms
87,532 KB
testcase_08 AC 130 ms
87,620 KB
testcase_09 AC 130 ms
87,444 KB
testcase_10 AC 130 ms
87,340 KB
testcase_11 AC 130 ms
87,384 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 125 ms
87,628 KB
testcase_15 AC 126 ms
87,572 KB
testcase_16 AC 123 ms
87,324 KB
testcase_17 AC 123 ms
87,932 KB
testcase_18 AC 122 ms
87,712 KB
testcase_19 AC 122 ms
87,328 KB
testcase_20 AC 130 ms
89,400 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 202 ms
93,528 KB
testcase_24 AC 168 ms
93,372 KB
testcase_25 AC 223 ms
95,768 KB
testcase_26 AC 226 ms
94,868 KB
testcase_27 AC 162 ms
92,412 KB
testcase_28 AC 152 ms
92,632 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 121 ms
87,576 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
        if count == 3000:
            print("No")
            exit()
print("No")
0