結果
| 問題 |
No.1750 ラムドスウイルスの感染拡大-hard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-20 01:32:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 715 bytes |
| コンパイル時間 | 270 ms |
| コンパイル使用メモリ | 82,740 KB |
| 実行使用メモリ | 67,664 KB |
| 最終ジャッジ日時 | 2025-01-02 05:24:26 |
| 合計ジャッジ時間 | 3,470 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 4 |
| other | RE * 30 |
ソースコード
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])