結果

問題 No.1588 Connection
ユーザー ayaoniayaoni
提出日時 2021-07-09 01:23:19
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,097 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 95,076 KB
平均クエリ数 521.09
最終ジャッジ日時 2023-09-24 11:56:23
合計ジャッジ時間 7,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 129 ms
87,324 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 124 ms
87,436 KB
testcase_10 AC 127 ms
87,208 KB
testcase_11 AC 127 ms
87,640 KB
testcase_12 AC 189 ms
93,908 KB
testcase_13 AC 152 ms
92,368 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 268 ms
94,820 KB
testcase_22 AC 266 ms
95,076 KB
testcase_23 AC 195 ms
94,096 KB
testcase_24 AC 157 ms
92,148 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 264 ms
94,036 KB
testcase_30 AC 258 ms
93,432 KB
testcase_31 AC 123 ms
87,264 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
0