結果

問題 No.1400 すごろくで世界旅行
ユーザー takelifetimetakelifetime
提出日時 2021-02-20 00:17:31
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 648 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 474,044 KB
最終ジャッジ日時 2023-10-17 02:27:35
合計ジャッジ時間 9,664 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 37 ms
53,564 KB
testcase_02 AC 36 ms
53,564 KB
testcase_03 AC 85 ms
75,992 KB
testcase_04 AC 58 ms
68,484 KB
testcase_05 AC 60 ms
70,624 KB
testcase_06 AC 166 ms
79,144 KB
testcase_07 AC 337 ms
79,140 KB
testcase_08 AC 88 ms
76,052 KB
testcase_09 AC 87 ms
76,284 KB
testcase_10 AC 117 ms
76,380 KB
testcase_11 AC 78 ms
75,920 KB
testcase_12 AC 1,801 ms
114,580 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

v, d = map(int, input().split())
e = [[x == "1" for x in input()] for _ in range(v)]

def power(a, b):
    c = [[False] * v for _ in range(v)]
    for i in range(v):
        for j in range(v):
            for k in range(v):
                if a[i][k] & b[k][j]:
                    c[i][j] = True
                    break
    return c

digits = len(bin(d)[2:])

ans = [[True if i == j else False for j in range(v)] for i in range(v)]

for i in range(digits):
    if d & 1:
        ans = power(ans, e)
    e = power(e, e)
    d >>= 1

for row in ans:
    for x in row:
        if x == False:
            print("No")
            exit()

print("Yes")
0