結果

問題 No.1750 ラムドスウイルスの感染拡大-hard
ユーザー shinichishinichi
提出日時 2021-11-20 01:32:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 1,125 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 30,456 KB
最終ジャッジ日時 2023-08-30 14:29:37
合計ジャッジ時間 13,023 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
29,572 KB
testcase_01 AC 135 ms
29,568 KB
testcase_02 AC 133 ms
29,624 KB
testcase_03 AC 136 ms
29,608 KB
testcase_04 AC 146 ms
29,832 KB
testcase_05 AC 134 ms
29,620 KB
testcase_06 AC 136 ms
29,604 KB
testcase_07 AC 137 ms
29,636 KB
testcase_08 AC 186 ms
30,380 KB
testcase_09 AC 190 ms
30,204 KB
testcase_10 AC 188 ms
30,264 KB
testcase_11 AC 177 ms
30,256 KB
testcase_12 AC 195 ms
30,440 KB
testcase_13 AC 189 ms
30,452 KB
testcase_14 AC 407 ms
30,304 KB
testcase_15 AC 411 ms
30,236 KB
testcase_16 AC 415 ms
30,456 KB
testcase_17 AC 420 ms
30,384 KB
testcase_18 AC 429 ms
30,204 KB
testcase_19 AC 413 ms
30,344 KB
testcase_20 AC 311 ms
30,400 KB
testcase_21 AC 342 ms
30,448 KB
testcase_22 AC 179 ms
29,916 KB
testcase_23 AC 403 ms
30,336 KB
testcase_24 AC 169 ms
29,900 KB
testcase_25 AC 211 ms
29,984 KB
testcase_26 AC 163 ms
29,792 KB
testcase_27 AC 137 ms
29,552 KB
testcase_28 AC 138 ms
29,612 KB
testcase_29 AC 138 ms
29,700 KB
testcase_30 AC 181 ms
29,816 KB
testcase_31 AC 179 ms
29,956 KB
testcase_32 AC 176 ms
29,900 KB
testcase_33 AC 177 ms
29,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import numpy as np

N, M, T = map(int, input().split())
A = np.zeros(shape=(N, N), dtype=np.int64)
for _ in range(M):
    s, t = map(int, input().split())
    A[s, t] = 1
    A[t, s] = 1


mod = 998244353

def mat_mul(A, B, MOD):
    A1, A2 = A >> 15, A & (1 << 15) - 1
    B1, B2 = B >> 15, B & (1 << 15) - 1
    AB1 = np.dot(A1, B1) % MOD
    AB2 = np.dot(A2, B2)
    AB3 = np.dot(A1+A2, B1+B2) - AB1 - AB2
    return ((AB1 << 30) + (AB3 << 15) + AB2) % MOD


def mat_pow(A, K):
    P = np.eye(len(A), dtype=np.int64)
    while K:
        if K & 1:
            P = mat_mul(A, P, mod)
        A = mat_mul(A, A, mod)
        K >>= 1
    return P

P = mat_pow(A, T)
print(P[0, 0])
0