結果

問題 No.1588 Connection
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-07-08 23:18:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 249 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 94,456 KB
平均クエリ数 562.31
最終ジャッジ日時 2023-09-24 11:35:48
合計ジャッジ時間 6,695 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
87,728 KB
testcase_01 AC 111 ms
87,660 KB
testcase_02 AC 109 ms
87,584 KB
testcase_03 AC 109 ms
87,096 KB
testcase_04 AC 112 ms
87,696 KB
testcase_05 AC 110 ms
87,368 KB
testcase_06 AC 114 ms
86,820 KB
testcase_07 AC 114 ms
87,508 KB
testcase_08 AC 118 ms
87,400 KB
testcase_09 AC 120 ms
87,544 KB
testcase_10 AC 119 ms
87,496 KB
testcase_11 AC 116 ms
87,764 KB
testcase_12 AC 179 ms
92,756 KB
testcase_13 AC 181 ms
92,980 KB
testcase_14 AC 114 ms
86,804 KB
testcase_15 AC 114 ms
87,584 KB
testcase_16 AC 110 ms
87,692 KB
testcase_17 AC 111 ms
87,276 KB
testcase_18 AC 116 ms
86,844 KB
testcase_19 AC 115 ms
86,908 KB
testcase_20 AC 121 ms
89,320 KB
testcase_21 AC 249 ms
94,456 KB
testcase_22 AC 242 ms
94,408 KB
testcase_23 AC 182 ms
93,036 KB
testcase_24 AC 151 ms
92,748 KB
testcase_25 AC 184 ms
93,612 KB
testcase_26 AC 183 ms
94,420 KB
testcase_27 AC 137 ms
91,896 KB
testcase_28 AC 133 ms
88,476 KB
testcase_29 AC 233 ms
93,368 KB
testcase_30 AC 238 ms
93,512 KB
testcase_31 AC 106 ms
86,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

500*500

黒マスから、次の黒マスを3回以内に見付けられればおk

"""

import sys
from sys import stdin
from collections import deque

def ask(x,y):

    if not (0 <= x < N and 0 <= y < N):
        return

    if ans[x][y] == None:
        print (x+1,y+1,flush=True)
        cat = stdin.readline()[:-1]

        if cat == "Black":
            ans[x][y] = 1
            q.append((x,y))
        elif cat == "White":
            ans[x][y] = 0
        else:
            assert False
            sys.exit()
        

N,M = map(int,stdin.readline().split())

ans = [[None] * N for i in range(N)]

q = deque()

ans[0][0] = 1
ans[-1][-1] = 1

q.append((0,0))

while q:

    x,y = q.popleft()
    ask(x-1,y)
    ask(x+1,y)
    ask(x,y-1)
    ask(x,y+1)

if ans[-2][-1] == 1 or ans[-1][-2] == 1:
    print ("Yes")
else:
    print ("No")
0