結果

問題 No.1588 Connection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-14 23:28:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 94,672 KB
平均クエリ数 119.81
最終ジャッジ日時 2023-09-24 12:10:26
合計ジャッジ時間 6,642 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 123 ms
87,672 KB
testcase_02 AC 124 ms
87,964 KB
testcase_03 AC 123 ms
87,600 KB
testcase_04 AC 122 ms
87,820 KB
testcase_05 AC 123 ms
87,424 KB
testcase_06 AC 124 ms
87,448 KB
testcase_07 AC 122 ms
87,692 KB
testcase_08 AC 128 ms
87,436 KB
testcase_09 AC 128 ms
87,540 KB
testcase_10 AC 128 ms
88,104 KB
testcase_11 AC 130 ms
87,288 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 123 ms
87,720 KB
testcase_15 AC 125 ms
87,484 KB
testcase_16 AC 125 ms
87,536 KB
testcase_17 AC 122 ms
87,284 KB
testcase_18 AC 124 ms
88,080 KB
testcase_19 AC 123 ms
87,928 KB
testcase_20 AC 128 ms
89,776 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 133 ms
89,804 KB
testcase_26 AC 132 ms
89,132 KB
testcase_27 AC 127 ms
87,628 KB
testcase_28 AC 124 ms
88,092 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 122 ms
87,336 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(x+1,y+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