結果

問題 No.1588 Connection
ユーザー horitaka1999horitaka1999
提出日時 2021-07-08 23:33:49
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 256 ms
使用メモリ 103,504 KB
平均クエリ数 551.28
最終ジャッジ日時 2023-02-15 01:15:56
合計ジャッジ時間 7,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 123 ms
90,752 KB
testcase_01 AC 118 ms
90,452 KB
testcase_02 AC 119 ms
90,608 KB
testcase_03 AC 119 ms
91,392 KB
testcase_04 AC 121 ms
91,292 KB
testcase_05 AC 120 ms
91,080 KB
testcase_06 AC 126 ms
91,440 KB
testcase_07 AC 118 ms
90,632 KB
testcase_08 AC 126 ms
91,332 KB
testcase_09 AC 129 ms
91,476 KB
testcase_10 AC 130 ms
91,676 KB
testcase_11 AC 131 ms
91,320 KB
testcase_12 AC 226 ms
97,800 KB
testcase_13 AC 239 ms
97,752 KB
testcase_14 AC 122 ms
91,536 KB
testcase_15 AC 125 ms
91,812 KB
testcase_16 AC 121 ms
91,240 KB
testcase_17 AC 128 ms
91,128 KB
testcase_18 AC 123 ms
91,420 KB
testcase_19 AC 131 ms
91,632 KB
testcase_20 AC 128 ms
93,608 KB
testcase_21 AC 311 ms
102,712 KB
testcase_22 AC 309 ms
102,788 KB
testcase_23 AC 221 ms
97,004 KB
testcase_24 AC 174 ms
96,292 KB
testcase_25 AC 257 ms
103,028 KB
testcase_26 AC 251 ms
103,504 KB
testcase_27 AC 172 ms
96,740 KB
testcase_28 AC 162 ms
96,416 KB
testcase_29 AC 327 ms
99,552 KB
testcase_30 AC 329 ms
98,852 KB
testcase_31 AC 121 ms
90,712 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