結果

問題 No.1588 Connection
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-07-09 00:24:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 99,384 KB
平均クエリ数 562.59
最終ジャッジ日時 2023-09-24 11:53:57
合計ジャッジ時間 6,328 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
87,252 KB
testcase_01 AC 90 ms
87,300 KB
testcase_02 AC 92 ms
87,112 KB
testcase_03 AC 91 ms
86,860 KB
testcase_04 AC 93 ms
87,536 KB
testcase_05 AC 95 ms
87,420 KB
testcase_06 AC 93 ms
87,144 KB
testcase_07 AC 93 ms
87,520 KB
testcase_08 AC 99 ms
86,888 KB
testcase_09 AC 95 ms
87,740 KB
testcase_10 AC 101 ms
87,584 KB
testcase_11 AC 101 ms
87,720 KB
testcase_12 AC 172 ms
93,500 KB
testcase_13 AC 194 ms
93,396 KB
testcase_14 AC 93 ms
86,860 KB
testcase_15 AC 95 ms
87,508 KB
testcase_16 AC 93 ms
87,076 KB
testcase_17 AC 95 ms
87,372 KB
testcase_18 AC 95 ms
87,220 KB
testcase_19 AC 96 ms
87,156 KB
testcase_20 AC 97 ms
87,260 KB
testcase_21 AC 261 ms
99,384 KB
testcase_22 AC 259 ms
98,508 KB
testcase_23 AC 175 ms
94,476 KB
testcase_24 AC 133 ms
92,332 KB
testcase_25 AC 194 ms
97,812 KB
testcase_26 AC 192 ms
98,876 KB
testcase_27 AC 122 ms
91,436 KB
testcase_28 AC 115 ms
91,068 KB
testcase_29 AC 256 ms
94,084 KB
testcase_30 AC 232 ms
94,164 KB
testcase_31 AC 87 ms
87,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
s=[[-1]*(n+1) for i in range(n+1)]
s[1][1]=1
s[n][n]=1
delta=[(1,0),(-1,0),(0,1),(0,-1)]
from _collections import deque


dp=[[10**18]*(n+1) for i in range(n+1)]
dp[1][1]=0
data=deque([(1,1)])
while data:
    i,j=data.popleft()
    for di,dj in delta:
        if not (1<=i+di<=n and 1<=j+dj<=n):continue
        x=i+di
        y=j+dj
        if s[x][y]==-1:
            print(x,y)
            t=input()
            if t[0]=="B":
                s[x][y]=1
            else:
                s[x][y]=0
        if s[x][y]==1 and dp[x][y]>dp[i][j]+1:
            dp[x][y]=dp[i][j]+1
            data.append((x,y))

print("Yes" if dp[n][n]<10**17 else "No")


0