結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー flygonflygon
提出日時 2023-06-16 23:21:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 92,088 KB
最終ジャッジ日時 2023-09-06 22:22:22
合計ジャッジ時間 16,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,028 KB
testcase_01 AC 70 ms
71,336 KB
testcase_02 AC 71 ms
71,176 KB
testcase_03 AC 70 ms
70,924 KB
testcase_04 AC 659 ms
90,736 KB
testcase_05 AC 70 ms
71,072 KB
testcase_06 AC 71 ms
70,932 KB
testcase_07 AC 71 ms
70,908 KB
testcase_08 AC 648 ms
90,380 KB
testcase_09 AC 706 ms
90,712 KB
testcase_10 AC 696 ms
90,864 KB
testcase_11 AC 704 ms
90,628 KB
testcase_12 AC 701 ms
90,768 KB
testcase_13 AC 706 ms
90,948 KB
testcase_14 AC 705 ms
90,700 KB
testcase_15 AC 396 ms
81,860 KB
testcase_16 AC 645 ms
88,364 KB
testcase_17 AC 655 ms
88,244 KB
testcase_18 AC 642 ms
88,160 KB
testcase_19 AC 393 ms
82,144 KB
testcase_20 AC 634 ms
88,284 KB
testcase_21 AC 531 ms
85,384 KB
testcase_22 AC 394 ms
81,796 KB
testcase_23 AC 312 ms
80,364 KB
testcase_24 AC 668 ms
88,364 KB
testcase_25 AC 124 ms
77,544 KB
testcase_26 AC 536 ms
85,416 KB
testcase_27 AC 665 ms
88,372 KB
testcase_28 AC 72 ms
70,936 KB
testcase_29 AC 72 ms
71,180 KB
testcase_30 AC 554 ms
92,088 KB
testcase_31 AC 559 ms
90,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
se = {"U":0,"F":1,"W":2,"P":3}
s = [[] for i in range(5)]
for i in range(n):
    si,ai = input().split()
    s[se[si]].append(int(ai))

mod = 998244353
ans = 1
for i in range(4):
    cnt = 0
    tot = sum(s[i])
    for j in s[i]:
        if i != 3:
            cnt += (pow(n-1, j, mod) - pow(n-2, j, mod))*pow(n-1, tot-j, mod)
        else:
            cnt += pow(n-1, j, mod) *pow(n-1, tot-j, mod)
        cnt %= mod
    ans *= cnt
    ans %= mod
print(ans)
    
0