結果
問題 |
No.1400 すごろくで世界旅行
|
ユーザー |
👑 ![]() |
提出日時 | 2021-02-19 23:01:14 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,038 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 78,688 KB |
最終ジャッジ日時 | 2024-09-16 21:51:02 |
合計ジャッジ時間 | 7,263 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 TLE * 1 -- * 3 |
ソースコード
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")