結果

問題 No.1340 おーじ君をさがせ
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-16 03:51:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 845 bytes
コンパイル時間 1,525 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 81,996 KB
最終ジャッジ日時 2023-08-17 21:41:23
合計ジャッジ時間 35,130 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,420 KB
testcase_01 AC 74 ms
71,340 KB
testcase_02 AC 75 ms
70,944 KB
testcase_03 AC 75 ms
71,240 KB
testcase_04 AC 75 ms
71,080 KB
testcase_05 AC 73 ms
71,228 KB
testcase_06 AC 73 ms
71,332 KB
testcase_07 AC 73 ms
71,380 KB
testcase_08 AC 73 ms
71,112 KB
testcase_09 AC 72 ms
71,288 KB
testcase_10 AC 86 ms
76,028 KB
testcase_11 AC 442 ms
77,076 KB
testcase_12 AC 140 ms
76,660 KB
testcase_13 AC 495 ms
77,904 KB
testcase_14 AC 850 ms
77,300 KB
testcase_15 AC 710 ms
77,204 KB
testcase_16 AC 127 ms
76,648 KB
testcase_17 AC 289 ms
77,180 KB
testcase_18 AC 452 ms
76,912 KB
testcase_19 AC 98 ms
76,628 KB
testcase_20 AC 83 ms
76,428 KB
testcase_21 AC 475 ms
77,856 KB
testcase_22 AC 1,636 ms
81,996 KB
testcase_23 AC 474 ms
77,848 KB
testcase_24 TLE -
testcase_25 AC 140 ms
77,820 KB
testcase_26 AC 124 ms
77,500 KB
testcase_27 AC 118 ms
77,472 KB
testcase_28 AC 156 ms
77,664 KB
testcase_29 AC 106 ms
77,356 KB
testcase_30 AC 508 ms
77,920 KB
testcase_31 TLE -
testcase_32 AC 1,901 ms
78,412 KB
testcase_33 AC 1,887 ms
78,456 KB
testcase_34 AC 1,693 ms
77,928 KB
testcase_35 TLE -
testcase_36 AC 73 ms
71,256 KB
testcase_37 AC 99 ms
77,400 KB
testcase_38 TLE -
testcase_39 AC 584 ms
77,708 KB
testcase_40 AC 608 ms
77,940 KB
testcase_41 AC 611 ms
77,620 KB
testcase_42 AC 78 ms
76,296 KB
testcase_43 AC 77 ms
76,444 KB
testcase_44 AC 80 ms
76,352 KB
testcase_45 AC 78 ms
76,288 KB
testcase_46 AC 472 ms
77,964 KB
testcase_47 AC 492 ms
77,880 KB
testcase_48 AC 537 ms
77,944 KB
testcase_49 AC 525 ms
77,324 KB
testcase_50 AC 524 ms
77,384 KB
testcase_51 AC 525 ms
77,644 KB
testcase_52 AC 942 ms
77,360 KB
testcase_53 AC 917 ms
77,256 KB
testcase_54 AC 940 ms
77,180 KB
testcase_55 AC 741 ms
78,152 KB
testcase_56 AC 80 ms
76,308 KB
testcase_57 WA -
testcase_58 AC 75 ms
71,348 KB
testcase_59 AC 339 ms
76,740 KB
testcase_60 AC 72 ms
71,360 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, t = map(int, input().split())
A = [[0]*n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    A[b][a] = 1
#print(A)
mod = 10**9+7
# A*B
def mat_mul(A, B, mod):
    C = [[0]*len(B[0]) for i in range(len(A))]
    for i in range(len(A)):
        for k in range(len(B)):
            for j in range(len(B[0])):
                C[i][j] = (C[i][j] + A[i][k]*B[k][j])%mod
    return C

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

X = [0]*n
X[0] = 1
A = mat_pow(A, t, mod)
ans = 0
for i in range(n):
    s = 0
    for j in range(n):
        s += A[i][j]*X[j]
    if s:
        ans += 1
#print(A)
print(ans)
0