結果

問題 No.1588 Connection
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-14 23:33:14
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 96,256 KB
平均クエリ数 551.19
最終ジャッジ日時 2023-09-24 12:10:34
合計ジャッジ時間 7,591 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
87,992 KB
testcase_01 AC 124 ms
87,852 KB
testcase_02 AC 125 ms
87,608 KB
testcase_03 AC 124 ms
86,988 KB
testcase_04 AC 124 ms
87,936 KB
testcase_05 AC 125 ms
87,844 KB
testcase_06 AC 126 ms
87,084 KB
testcase_07 AC 125 ms
87,576 KB
testcase_08 AC 128 ms
87,616 KB
testcase_09 AC 129 ms
87,416 KB
testcase_10 AC 131 ms
87,732 KB
testcase_11 AC 131 ms
87,356 KB
testcase_12 AC 213 ms
94,188 KB
testcase_13 AC 215 ms
93,316 KB
testcase_14 AC 125 ms
87,648 KB
testcase_15 AC 125 ms
87,616 KB
testcase_16 AC 123 ms
87,488 KB
testcase_17 AC 125 ms
87,172 KB
testcase_18 AC 124 ms
87,940 KB
testcase_19 AC 123 ms
87,704 KB
testcase_20 AC 127 ms
89,268 KB
testcase_21 AC 294 ms
96,256 KB
testcase_22 AC 298 ms
96,184 KB
testcase_23 AC 201 ms
94,204 KB
testcase_24 AC 167 ms
93,224 KB
testcase_25 AC 225 ms
95,332 KB
testcase_26 AC 227 ms
94,988 KB
testcase_27 AC 158 ms
92,548 KB
testcase_28 AC 154 ms
92,488 KB
testcase_29 AC 277 ms
94,100 KB
testcase_30 AC 293 ms
94,832 KB
testcase_31 AC 123 ms
87,456 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:
    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

print("No")
0