結果
問題 | No.623 fudan no modulus to tigau |
ユーザー | Ryuto |
提出日時 | 2017-12-23 00:44:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 80 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 1,112 ms |
コンパイル使用メモリ | 86,764 KB |
実行使用メモリ | 75,812 KB |
最終ジャッジ日時 | 2023-08-22 15:09:08 |
合計ジャッジ時間 | 2,264 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
75,584 KB |
testcase_01 | AC | 75 ms
75,572 KB |
testcase_02 | AC | 75 ms
75,812 KB |
testcase_03 | AC | 75 ms
75,560 KB |
testcase_04 | AC | 76 ms
75,560 KB |
testcase_05 | AC | 76 ms
75,540 KB |
testcase_06 | AC | 76 ms
75,744 KB |
testcase_07 | AC | 78 ms
75,776 KB |
testcase_08 | AC | 80 ms
75,752 KB |
testcase_09 | AC | 76 ms
75,788 KB |
testcase_10 | AC | 76 ms
75,792 KB |
testcase_11 | AC | 77 ms
75,732 KB |
testcase_12 | AC | 69 ms
71,468 KB |
testcase_13 | AC | 68 ms
71,004 KB |
ソースコード
#!/usr/bin/env python def fc(funcs, n): fc = [1, n] for func in funcs: if func[0] == 1: fc.append((fc[func[1]]+fc[func[2]]) % 998244353) elif func[0] == 2: fc.append((func[1]*fc[func[2]]) % 998244353) elif func[0] == 3: fc.append((fc[func[1]]*fc[func[2]]) % 998244353) return fc[-1] n = int(input()) funcs = [] for i in range(n-1): funcs.append([int(x) for x in input().split()]) q = int(input()) indats = [int(x) for x in input().split()] for indat in indats: print(fc(funcs, indat) % 998244353)