結果

問題 No.2356 Back Door Tour in Four Seasons
コンテスト
ユーザー flygon
提出日時 2023-06-16 23:21:18
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 322 ms / 2,000 ms
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 321 ms
コンパイル使用メモリ 85,568 KB
実行使用メモリ 94,752 KB
最終ジャッジ日時 2026-03-10 20:31:12
合計ジャッジ時間 7,678 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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