結果

問題 No.1340 おーじ君をさがせ
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-16 04:09:37
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,047 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 81,872 KB
最終ジャッジ日時 2023-08-17 21:57:39
合計ジャッジ時間 34,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,352 KB
testcase_01 AC 73 ms
71,352 KB
testcase_02 AC 73 ms
71,320 KB
testcase_03 AC 73 ms
71,156 KB
testcase_04 AC 73 ms
71,456 KB
testcase_05 AC 71 ms
71,176 KB
testcase_06 AC 72 ms
71,156 KB
testcase_07 AC 73 ms
71,132 KB
testcase_08 AC 71 ms
71,324 KB
testcase_09 AC 71 ms
71,296 KB
testcase_10 AC 84 ms
76,060 KB
testcase_11 AC 443 ms
77,200 KB
testcase_12 AC 142 ms
76,548 KB
testcase_13 AC 499 ms
78,092 KB
testcase_14 AC 846 ms
77,264 KB
testcase_15 AC 711 ms
76,900 KB
testcase_16 AC 125 ms
76,592 KB
testcase_17 AC 289 ms
77,304 KB
testcase_18 AC 451 ms
77,092 KB
testcase_19 AC 97 ms
76,424 KB
testcase_20 AC 82 ms
76,280 KB
testcase_21 AC 470 ms
77,812 KB
testcase_22 AC 1,609 ms
81,872 KB
testcase_23 AC 470 ms
77,856 KB
testcase_24 TLE -
testcase_25 AC 139 ms
77,772 KB
testcase_26 AC 127 ms
77,704 KB
testcase_27 AC 119 ms
77,448 KB
testcase_28 AC 156 ms
77,664 KB
testcase_29 AC 107 ms
77,432 KB
testcase_30 AC 503 ms
77,976 KB
testcase_31 TLE -
testcase_32 AC 1,872 ms
78,360 KB
testcase_33 AC 1,859 ms
78,500 KB
testcase_34 AC 1,678 ms
78,056 KB
testcase_35 TLE -
testcase_36 AC 73 ms
71,456 KB
testcase_37 AC 100 ms
77,436 KB
testcase_38 AC 1,997 ms
78,188 KB
testcase_39 AC 583 ms
77,640 KB
testcase_40 AC 607 ms
77,808 KB
testcase_41 AC 604 ms
77,848 KB
testcase_42 AC 79 ms
76,284 KB
testcase_43 AC 80 ms
76,272 KB
testcase_44 AC 81 ms
76,336 KB
testcase_45 AC 81 ms
76,232 KB
testcase_46 AC 468 ms
77,664 KB
testcase_47 AC 492 ms
77,800 KB
testcase_48 AC 533 ms
78,028 KB
testcase_49 AC 529 ms
77,304 KB
testcase_50 AC 525 ms
77,308 KB
testcase_51 AC 524 ms
77,168 KB
testcase_52 AC 940 ms
77,336 KB
testcase_53 AC 922 ms
77,144 KB
testcase_54 AC 941 ms
77,104 KB
testcase_55 AC 737 ms
78,076 KB
testcase_56 AC 81 ms
76,216 KB
testcase_57 AC 81 ms
76,040 KB
testcase_58 AC 73 ms
71,288 KB
testcase_59 AC 339 ms
76,504 KB
testcase_60 AC 72 ms
71,264 KB
testcase_61 AC 340 ms
76,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1+(1<<30)

def main():

    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)
    # 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)

if __name__ == '__main__':
    main()
0