結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー flygon
提出日時 2023-06-16 23:21:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 689 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 90,672 KB
最終ジャッジ日時 2024-06-24 16:33:58
合計ジャッジ時間 14,979 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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