結果

問題 No.1340 おーじ君をさがせ
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-28 15:56:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 851 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,504 KB
最終ジャッジ日時 2024-04-24 19:49:49
合計ジャッジ時間 8,028 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
21,504 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 26 ms
10,496 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 29 ms
10,624 KB
testcase_05 AC 27 ms
10,496 KB
testcase_06 AC 26 ms
10,624 KB
testcase_07 AC 27 ms
10,624 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 43 ms
10,496 KB
testcase_11 AC 1,430 ms
10,880 KB
testcase_12 AC 249 ms
10,880 KB
testcase_13 AC 1,070 ms
10,880 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 197 ms
10,752 KB
testcase_17 AC 807 ms
10,880 KB
testcase_18 AC 1,423 ms
10,752 KB
testcase_19 AC 94 ms
10,880 KB
testcase_20 AC 39 ms
10,624 KB
testcase_21 AC 1,441 ms
10,880 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def mat_mul(A, B):
    res = [[0] * len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for k in range(len(A[0])):
            for j in range(len(B[0])):
                res[i][j] |= (A[i][k] & B[k][j])
    return res


def mat_pow(A, n):
    size = len(A)
    res = [[0] * size for _ in range(size)]
    for i in range(size):
        res[i][i] = 1
    while n:
        if n & 1:
            res = mat_mul(res, A)
        A = mat_mul(A, A)
        n >>= 1
    return res


N, M, T = map(int, input().split())
deg = [0] * N
A = [[0]*(N+1) for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    deg[a] += 1
    A[a][b] = 1
for i in range(N):
    if not deg[i]:
        A[i][N] = 1

B = mat_pow(A, T)
ans = sum(B[0][:N])
print(ans)
0