結果

問題 No.1340 おーじ君をさがせ
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-05-01 12:39:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,161 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 2,281 ms
コンパイル使用メモリ 86,612 KB
実行使用メモリ 81,844 KB
最終ジャッジ日時 2023-09-27 02:27:42
合計ジャッジ時間 21,903 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,208 KB
testcase_01 AC 78 ms
71,404 KB
testcase_02 AC 78 ms
71,316 KB
testcase_03 AC 79 ms
71,296 KB
testcase_04 AC 78 ms
71,500 KB
testcase_05 AC 80 ms
71,192 KB
testcase_06 AC 78 ms
71,164 KB
testcase_07 AC 75 ms
71,156 KB
testcase_08 AC 73 ms
71,364 KB
testcase_09 AC 71 ms
71,296 KB
testcase_10 AC 95 ms
76,272 KB
testcase_11 AC 251 ms
76,732 KB
testcase_12 AC 107 ms
76,096 KB
testcase_13 AC 366 ms
77,812 KB
testcase_14 AC 439 ms
76,948 KB
testcase_15 AC 377 ms
76,824 KB
testcase_16 AC 102 ms
76,232 KB
testcase_17 AC 179 ms
76,960 KB
testcase_18 AC 255 ms
76,756 KB
testcase_19 AC 88 ms
76,472 KB
testcase_20 AC 80 ms
76,036 KB
testcase_21 AC 287 ms
77,800 KB
testcase_22 AC 1,161 ms
81,844 KB
testcase_23 AC 285 ms
77,644 KB
testcase_24 AC 1,025 ms
78,420 KB
testcase_25 AC 136 ms
77,676 KB
testcase_26 AC 118 ms
77,908 KB
testcase_27 AC 115 ms
77,484 KB
testcase_28 AC 138 ms
77,692 KB
testcase_29 AC 102 ms
77,192 KB
testcase_30 AC 294 ms
77,592 KB
testcase_31 AC 1,013 ms
78,336 KB
testcase_32 AC 958 ms
78,300 KB
testcase_33 AC 954 ms
78,148 KB
testcase_34 AC 865 ms
77,928 KB
testcase_35 AC 1,030 ms
78,260 KB
testcase_36 AC 74 ms
71,428 KB
testcase_37 AC 98 ms
77,360 KB
testcase_38 AC 1,015 ms
78,324 KB
testcase_39 AC 332 ms
77,540 KB
testcase_40 AC 342 ms
77,520 KB
testcase_41 AC 345 ms
77,680 KB
testcase_42 AC 77 ms
76,184 KB
testcase_43 AC 79 ms
76,320 KB
testcase_44 AC 79 ms
76,128 KB
testcase_45 AC 77 ms
76,112 KB
testcase_46 AC 275 ms
77,792 KB
testcase_47 AC 288 ms
77,748 KB
testcase_48 AC 311 ms
77,792 KB
testcase_49 AC 291 ms
77,172 KB
testcase_50 AC 292 ms
76,924 KB
testcase_51 AC 294 ms
77,260 KB
testcase_52 AC 489 ms
77,016 KB
testcase_53 AC 481 ms
77,176 KB
testcase_54 AC 487 ms
76,908 KB
testcase_55 AC 407 ms
77,840 KB
testcase_56 AC 80 ms
76,336 KB
testcase_57 AC 80 ms
76,360 KB
testcase_58 AC 74 ms
71,500 KB
testcase_59 AC 208 ms
75,936 KB
testcase_60 AC 75 ms
71,008 KB
testcase_61 AC 205 ms
75,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244853

def mat_mul(a, b):
    n = len(a)
    res = [[0] * n for i in range(n)]
    for i in range(n):
        for k in range(n):
            for j in range(n):
                res[i][j] += a[i][k] * b[k][j]
                res[i][j] %= mod
    return res

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

n, m, t = map(int, input().split())
G = [[0] * n for i in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a][b] = 1
G2 = mat_pow(G, t)
ans = 0
for i in range(n):
    if G2[0][i] > 0:
        ans += 1
print(ans)
0