結果

問題 No.1588 Connection
ユーザー ayaoniayaoni
提出日時 2021-07-09 01:25:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 1,110 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 94,904 KB
平均クエリ数 521.69
最終ジャッジ日時 2023-09-24 11:56:31
合計ジャッジ時間 7,163 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
87,212 KB
testcase_01 AC 124 ms
87,192 KB
testcase_02 AC 120 ms
87,888 KB
testcase_03 AC 122 ms
87,276 KB
testcase_04 AC 121 ms
87,892 KB
testcase_05 AC 119 ms
87,044 KB
testcase_06 AC 118 ms
87,204 KB
testcase_07 AC 117 ms
87,844 KB
testcase_08 AC 121 ms
87,268 KB
testcase_09 AC 123 ms
87,188 KB
testcase_10 AC 124 ms
87,560 KB
testcase_11 AC 128 ms
87,824 KB
testcase_12 AC 188 ms
93,500 KB
testcase_13 AC 150 ms
92,376 KB
testcase_14 AC 120 ms
87,644 KB
testcase_15 AC 124 ms
87,440 KB
testcase_16 AC 120 ms
87,348 KB
testcase_17 AC 120 ms
87,492 KB
testcase_18 AC 123 ms
87,776 KB
testcase_19 AC 121 ms
87,404 KB
testcase_20 AC 127 ms
88,848 KB
testcase_21 AC 266 ms
94,220 KB
testcase_22 AC 261 ms
94,456 KB
testcase_23 AC 188 ms
94,260 KB
testcase_24 AC 152 ms
92,152 KB
testcase_25 AC 204 ms
94,504 KB
testcase_26 AC 200 ms
94,904 KB
testcase_27 AC 152 ms
92,924 KB
testcase_28 AC 141 ms
88,632 KB
testcase_29 AC 263 ms
93,952 KB
testcase_30 AC 257 ms
93,824 KB
testcase_31 AC 120 ms
87,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,M = MI()

board = [[-1]*N for _ in range(N)]
board[0][0] = 1
board[-1][-1] = 1

directions = [(-1,0),(1,0),(0,-1),(0,1)]
deq = deque([(0,0)])
while deq:
    i,j = deq.pop()
    for di,dj in directions:
        ni,nj = i+di,j+dj
        if not (0 <= ni < N and 0 <= nj < N):
            continue
        if ni == nj == N-1:
            print('Yes',flush=True)
            exit()
        if board[ni][nj] != -1:
            continue
        print(ni+1,nj+1,flush=True)
        T = S()
        if T == 'Black':
            board[ni][nj] = 1
            deq.append((ni,nj))
        else:
            board[ni][nj] = 0

print('No')
0