結果

問題 No.1588 Connection
ユーザー horitaka1999horitaka1999
提出日時 2021-07-08 23:33:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 302 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,828 KB
実行使用メモリ 98,808 KB
平均クエリ数 551.28
最終ジャッジ日時 2023-09-24 11:41:36
合計ジャッジ時間 7,411 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
87,388 KB
testcase_01 AC 126 ms
87,528 KB
testcase_02 AC 119 ms
87,412 KB
testcase_03 AC 120 ms
87,912 KB
testcase_04 AC 119 ms
87,584 KB
testcase_05 AC 120 ms
87,172 KB
testcase_06 AC 120 ms
87,124 KB
testcase_07 AC 119 ms
87,160 KB
testcase_08 AC 124 ms
87,608 KB
testcase_09 AC 125 ms
87,388 KB
testcase_10 AC 124 ms
87,808 KB
testcase_11 AC 124 ms
87,852 KB
testcase_12 AC 198 ms
93,968 KB
testcase_13 AC 216 ms
94,672 KB
testcase_14 AC 118 ms
87,644 KB
testcase_15 AC 121 ms
87,756 KB
testcase_16 AC 118 ms
87,200 KB
testcase_17 AC 121 ms
87,780 KB
testcase_18 AC 118 ms
87,700 KB
testcase_19 AC 118 ms
87,976 KB
testcase_20 AC 126 ms
90,148 KB
testcase_21 AC 302 ms
98,716 KB
testcase_22 AC 298 ms
98,808 KB
testcase_23 AC 202 ms
94,228 KB
testcase_24 AC 166 ms
93,276 KB
testcase_25 AC 233 ms
97,808 KB
testcase_26 AC 230 ms
98,480 KB
testcase_27 AC 159 ms
93,388 KB
testcase_28 AC 148 ms
92,276 KB
testcase_29 AC 285 ms
94,668 KB
testcase_30 AC 269 ms
94,352 KB
testcase_31 AC 121 ms
87,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
Board = [[0] * N for _ in range(N)]
Board[0][0] = 1
Board[N-1][N-1] = 1
from collections import deque
q = deque()
q.append((0,0))
seen = [[False]* N for _ in range(N)]
def check(i,j):
    if 0 <= i < N and 0 <= j < N:
        return True
    else:
        return False
while q:
    i,j= q.popleft()
    seen[i][j] = True
    if i == N-1 and j == N-1:
        print('Yes')
        exit()
    for p,r in [(1,0),(-1,0),(0,-1),(0,1)]:
        if check(i+p,j+r) and not seen[i+p][j+r]:
            if i + p + 1 == N and j + r + 1 == N:
                print('Yes')
                exit()
            print(i+p+1,j+r+1)
            seen[i+p][j+r] = True
            t = input()
            if t == 'Black':
                q.append((i+p,j+r))
print('No')
0