結果

問題 No.2310 [Cherry 5th Tune A] Against Regret
ユーザー 2000 Ekiben2000 Ekiben
提出日時 2024-06-24 13:16:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 942 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-06-24 13:16:45
合計ジャッジ時間 13,695 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 56 ms
10,752 KB
testcase_03 AC 85 ms
11,136 KB
testcase_04 AC 99 ms
11,392 KB
testcase_05 AC 125 ms
11,392 KB
testcase_06 AC 53 ms
11,008 KB
testcase_07 AC 63 ms
11,136 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0