結果

問題 No.623 fudan no modulus to tigau
ユーザー ああいい
提出日時 2022-05-19 09:55:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 61,692 KB
最終ジャッジ日時 2024-09-17 15:25:08
合計ジャッジ時間 1,416 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353

n = int(input())
poly = []
for _ in range(n - 1):
    t,a,b = map(int,input().split())
    poly.append((t,a,b))
q = int(input())
x = list(map(int,input().split()))

for u in x:
    dat = [0] * 2
    dat[0] = 1
    dat[1] = u
    for t,a,b in poly:
        if t == 1:
            dat.append((dat[a] + dat[b]) % P)
        elif t == 2:
            dat.append((a * dat[b]) % P)
        else:
            dat.append(dat[a] * dat[b] % P)
    print(dat[n])
0