結果

問題 No.1400 すごろくで世界旅行
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-19 23:01:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,038 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 86,624 KB
実行使用メモリ 86,160 KB
最終ジャッジ日時 2023-10-15 04:21:28
合計ジャッジ時間 8,183 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,508 KB
testcase_01 AC 96 ms
71,656 KB
testcase_02 AC 95 ms
71,620 KB
testcase_03 AC 102 ms
76,600 KB
testcase_04 AC 102 ms
76,808 KB
testcase_05 AC 101 ms
76,904 KB
testcase_06 AC 112 ms
77,480 KB
testcase_07 AC 105 ms
77,640 KB
testcase_08 AC 102 ms
77,684 KB
testcase_09 AC 103 ms
76,904 KB
testcase_10 AC 105 ms
77,340 KB
testcase_11 AC 101 ms
76,912 KB
testcase_12 AC 113 ms
77,556 KB
testcase_13 AC 277 ms
80,996 KB
testcase_14 AC 171 ms
81,144 KB
testcase_15 AC 145 ms
80,964 KB
testcase_16 AC 307 ms
81,104 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
from collections import deque

V,D = map(int,stdin.readline().split())

E = [ stdin.readline()[:-1] for i in range(V) ]

for s in range(V):

    q = deque([s])
    d = [float("inf")] * (2*V)
    d[s] = 0
    

    while q:
        
        nowori = q.popleft()
        v = nowori
        side = 0

        if v >= V:
            v -= V
            side = 1

        for nex in range(V):
            if E[v][nex] == "1":
                nexori = nex + V * (side^1)
                if d[nexori] > d[nowori] + 1:
                    d[nexori] = d[nowori] + 1
                    q.append(nexori)

    #print (s,d)
    maxd = 0
    if D % 2 == 0:
        for i in range(V):
            maxd = max(maxd , d[i])
            if d[i] > D:
                print ("No")
                sys.exit()
    else:
        for i in range(V,2*V):
            maxd = max(maxd , d[i])
            if d[i] > D:
                print ("No")
                sys.exit()

    if maxd * 2 <= D:
        break
        

print ("Yes")
0