結果
| 問題 |
No.2310 [Cherry 5th Tune A] Against Regret
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-24 13:16:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 942 bytes |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-24 13:16:45 |
| 合計ジャッジ時間 | 13,695 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 1 -- * 21 |
ソースコード
import sys
input = sys.stdin.read
MOD = 998244353
data = input().split()
index = 0
N = int(data[index])
index += 1
X = [[0] * (N + 1) for _ in range(N + 1)]
for u in range(N + 1):
for v in range(N + 1):
X[u][v] = int(data[index])
index += 1
Q = int(data[index])
index += 1
results = []
for _ in range(Q):
K_q = int(data[index])
index += 1
operations = []
for _ in range(K_q):
A = int(data[index])
B = int(data[index + 1])
C = int(data[index + 2])
operations.append((A, B, C))
index += 3
M = [row[:] for row in X]
for (A, B, C) in operations:
M[A][B] = (M[A][B] + C) % MOD
dp = [0] * (N + 1)
dp[0] = 1
for u in range(N + 1):
for v in range(u + 1, N + 1):
if M[u][v] > 0:
dp[v] = (dp[v] + dp[u] * M[u][v]) % MOD
results.append(dp[N])
sys.stdout.write('\n'.join(map(str, results)) + '\n')