結果

問題 No.1588 Connection
ユーザー ayaoniayaoni
提出日時 2021-07-08 23:08:30
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,562 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 86,300 KB
実行使用メモリ 94,832 KB
平均クエリ数 488.69
最終ジャッジ日時 2023-09-24 11:32:24
合計ジャッジ時間 7,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 111 ms
87,432 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 114 ms
87,500 KB
testcase_10 AC 116 ms
86,980 KB
testcase_11 AC 118 ms
87,400 KB
testcase_12 AC 131 ms
87,808 KB
testcase_13 AC 125 ms
88,316 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 285 ms
94,828 KB
testcase_22 AC 254 ms
94,352 KB
testcase_23 AC 173 ms
93,124 KB
testcase_24 AC 141 ms
92,228 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 275 ms
94,136 KB
testcase_30 AC 283 ms
94,832 KB
testcase_31 AC 115 ms
87,568 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

directions0 = [(1,0),(0,1)]
directions1 = [(-1,0),(0,-1)]

deq = deque([(0,0)])
while deq:
    i,j = deq.pop()
    for di,dj in directions0:
        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
    for di,dj in directions1:
        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.appendleft((ni,nj))
        else:
            board[ni][nj] = 0
0