結果

問題 No.1340 おーじ君をさがせ
ユーザー brthyyjpbrthyyjp
提出日時 2021-01-16 03:54:39
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,046 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 81,892 KB
最終ジャッジ日時 2023-08-17 21:43:40
合計ジャッジ時間 34,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,104 KB
testcase_01 AC 74 ms
71,260 KB
testcase_02 AC 72 ms
71,184 KB
testcase_03 AC 74 ms
71,184 KB
testcase_04 AC 75 ms
71,524 KB
testcase_05 AC 74 ms
71,492 KB
testcase_06 AC 75 ms
71,496 KB
testcase_07 AC 71 ms
71,256 KB
testcase_08 AC 73 ms
71,012 KB
testcase_09 AC 73 ms
71,184 KB
testcase_10 AC 89 ms
76,296 KB
testcase_11 AC 450 ms
77,200 KB
testcase_12 AC 142 ms
76,568 KB
testcase_13 AC 498 ms
77,724 KB
testcase_14 AC 852 ms
77,296 KB
testcase_15 AC 713 ms
77,240 KB
testcase_16 AC 125 ms
76,572 KB
testcase_17 AC 288 ms
77,188 KB
testcase_18 AC 457 ms
77,124 KB
testcase_19 AC 96 ms
76,500 KB
testcase_20 AC 83 ms
76,256 KB
testcase_21 AC 470 ms
77,872 KB
testcase_22 AC 1,607 ms
81,892 KB
testcase_23 AC 474 ms
77,884 KB
testcase_24 TLE -
testcase_25 AC 139 ms
78,116 KB
testcase_26 AC 129 ms
77,776 KB
testcase_27 AC 120 ms
77,512 KB
testcase_28 AC 158 ms
77,716 KB
testcase_29 AC 106 ms
77,488 KB
testcase_30 AC 506 ms
77,880 KB
testcase_31 TLE -
testcase_32 AC 1,877 ms
78,468 KB
testcase_33 AC 1,855 ms
78,448 KB
testcase_34 AC 1,684 ms
78,060 KB
testcase_35 TLE -
testcase_36 AC 75 ms
71,380 KB
testcase_37 AC 103 ms
77,076 KB
testcase_38 TLE -
testcase_39 AC 587 ms
77,668 KB
testcase_40 AC 608 ms
78,180 KB
testcase_41 AC 608 ms
78,052 KB
testcase_42 AC 78 ms
76,256 KB
testcase_43 AC 79 ms
76,124 KB
testcase_44 AC 85 ms
76,028 KB
testcase_45 AC 84 ms
76,348 KB
testcase_46 AC 467 ms
77,788 KB
testcase_47 AC 498 ms
77,816 KB
testcase_48 AC 535 ms
77,684 KB
testcase_49 AC 533 ms
77,344 KB
testcase_50 AC 529 ms
77,304 KB
testcase_51 AC 526 ms
77,396 KB
testcase_52 AC 946 ms
77,072 KB
testcase_53 AC 925 ms
77,264 KB
testcase_54 AC 946 ms
77,184 KB
testcase_55 AC 740 ms
78,036 KB
testcase_56 AC 84 ms
76,312 KB
testcase_57 WA -
testcase_58 AC 76 ms
71,336 KB
testcase_59 AC 344 ms
76,440 KB
testcase_60 AC 74 ms
71,500 KB
testcase_61 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9+7

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