結果

問題 No.1340 おーじ君をさがせ
ユーザー rlangevinrlangevin
提出日時 2023-11-21 00:05:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,855 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 79,436 KB
最終ジャッジ日時 2023-11-21 00:05:48
合計ジャッジ時間 29,075 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 34 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 34 ms
53,460 KB
testcase_08 AC 34 ms
53,460 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 48 ms
64,304 KB
testcase_11 AC 364 ms
75,412 KB
testcase_12 AC 93 ms
68,244 KB
testcase_13 AC 427 ms
76,064 KB
testcase_14 AC 747 ms
75,540 KB
testcase_15 AC 601 ms
75,540 KB
testcase_16 AC 91 ms
66,196 KB
testcase_17 AC 229 ms
75,412 KB
testcase_18 AC 396 ms
75,412 KB
testcase_19 AC 56 ms
64,148 KB
testcase_20 AC 45 ms
62,100 KB
testcase_21 AC 388 ms
75,716 KB
testcase_22 AC 1,472 ms
79,436 KB
testcase_23 AC 390 ms
75,716 KB
testcase_24 AC 1,852 ms
76,612 KB
testcase_25 AC 79 ms
72,772 KB
testcase_26 AC 66 ms
70,724 KB
testcase_27 AC 61 ms
68,676 KB
testcase_28 AC 95 ms
73,412 KB
testcase_29 AC 50 ms
66,628 KB
testcase_30 AC 421 ms
75,716 KB
testcase_31 AC 1,855 ms
76,612 KB
testcase_32 AC 1,704 ms
76,612 KB
testcase_33 AC 1,660 ms
76,612 KB
testcase_34 AC 1,516 ms
76,356 KB
testcase_35 AC 1,826 ms
76,612 KB
testcase_36 AC 35 ms
53,460 KB
testcase_37 AC 43 ms
64,272 KB
testcase_38 AC 1,787 ms
76,612 KB
testcase_39 AC 486 ms
75,972 KB
testcase_40 AC 529 ms
75,972 KB
testcase_41 AC 509 ms
75,972 KB
testcase_42 AC 40 ms
59,840 KB
testcase_43 AC 39 ms
59,976 KB
testcase_44 AC 42 ms
62,240 KB
testcase_45 AC 43 ms
62,240 KB
testcase_46 AC 406 ms
75,972 KB
testcase_47 AC 403 ms
75,972 KB
testcase_48 AC 451 ms
75,972 KB
testcase_49 AC 438 ms
75,540 KB
testcase_50 AC 438 ms
75,540 KB
testcase_51 AC 439 ms
75,540 KB
testcase_52 AC 804 ms
75,796 KB
testcase_53 AC 807 ms
75,540 KB
testcase_54 AC 804 ms
75,796 KB
testcase_55 AC 636 ms
75,844 KB
testcase_56 AC 43 ms
62,236 KB
testcase_57 AC 43 ms
62,236 KB
testcase_58 AC 39 ms
53,460 KB
testcase_59 AC 269 ms
72,340 KB
testcase_60 AC 35 ms
53,460 KB
testcase_61 AC 269 ms
72,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def Matprod(A, B, mod, N):
    temp = [0] * N*N
    for i in range(N):
        for j in range(N):
            ij = i * N + j
            for k in range(N):
                temp[ij] += A[i*N+k] * B[k*N+j]
                temp[ij] %= mod
    return temp

def Matpow_Linear(A, M, mod, N):
    Mat = [0] * N*N
    for i in range(N):
        Mat[i*N+i] = 1
         
    while M:
        if M & 1:
            Mat = Matprod(Mat, A, mod, N)
        A = Matprod(A, A, mod, N)
        M >>= 1
    return Mat  

N, M, T = map(int, input().split())
N2 = N * N
dp = [0] * N2
for i in range(M):
    a, b = map(int, input().split())
    dp[a*N+b] += 1
    
mod = 999999937
dp = Matpow_Linear(dp, T, mod, N)
ans = 0
for i in range(N):
    if dp[i]:
        ans += 1
        
print(ans)
0