結果
| 問題 |
No.1750 ラムドスウイルスの感染拡大-hard
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-14 17:52:53 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 562 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 44,592 KB |
| 最終ジャッジ日時 | 2024-09-18 08:20:43 |
| 合計ジャッジ時間 | 20,181 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 20 |
ソースコード
import numpy as np
def matqpow2(base: "np.ndarray", exp: int, mod: int) -> "np.ndarray":
"""np矩阵快速幂"""
res = np.eye(*base.shape, dtype=np.int64)
while exp:
if exp & 1:
res = (res @ base) % mod
base = (base @ base) % mod
exp >>= 1
return res
n, m, k = map(int, input().split())
adjMatrix = [[0] * n for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
adjMatrix[u][v] = 1
adjMatrix[v][u] = 1
T = matqpow2(np.array(adjMatrix, np.int64), k, 998244353)
print(T[0][0])