結果

問題 No.1400 すごろくで世界旅行
ユーザー takelifetimetakelifetime
提出日時 2021-02-20 00:03:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 632 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 114,960 KB
最終ジャッジ日時 2023-10-17 01:48:01
合計ジャッジ時間 9,990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,540 KB
testcase_01 AC 35 ms
53,540 KB
testcase_02 AC 35 ms
53,540 KB
testcase_03 AC 77 ms
76,080 KB
testcase_04 AC 56 ms
68,512 KB
testcase_05 AC 58 ms
70,664 KB
testcase_06 AC 143 ms
79,220 KB
testcase_07 AC 252 ms
79,068 KB
testcase_08 AC 80 ms
76,140 KB
testcase_09 AC 80 ms
76,088 KB
testcase_10 AC 104 ms
76,456 KB
testcase_11 AC 72 ms
76,112 KB
testcase_12 AC 1,294 ms
114,960 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 = [list(map(int, list(input()))) for _ in range(v)]

def power(a, b):
    c = [[0] * 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] = 1
                    break
    return c

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

ans = [[1 if i == j else 0 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 == 0:
            print("No")
            exit()

print("Yes")
0