結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー titiatitia
提出日時 2023-06-20 08:19:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 716 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 105 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 20,348 KB
最終ジャッジ日時 2023-09-10 03:25:46
合計ジャッジ時間 14,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,916 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 16 ms
7,812 KB
testcase_03 AC 15 ms
7,832 KB
testcase_04 AC 605 ms
20,096 KB
testcase_05 AC 15 ms
7,860 KB
testcase_06 AC 16 ms
7,812 KB
testcase_07 AC 15 ms
7,800 KB
testcase_08 AC 695 ms
19,832 KB
testcase_09 AC 716 ms
20,024 KB
testcase_10 AC 711 ms
19,956 KB
testcase_11 AC 706 ms
20,348 KB
testcase_12 AC 701 ms
20,168 KB
testcase_13 AC 708 ms
20,032 KB
testcase_14 AC 706 ms
19,864 KB
testcase_15 AC 359 ms
14,184 KB
testcase_16 AC 662 ms
19,304 KB
testcase_17 AC 676 ms
19,368 KB
testcase_18 AC 661 ms
18,936 KB
testcase_19 AC 369 ms
14,148 KB
testcase_20 AC 635 ms
18,776 KB
testcase_21 AC 522 ms
17,216 KB
testcase_22 AC 363 ms
14,280 KB
testcase_23 AC 266 ms
12,600 KB
testcase_24 AC 670 ms
19,288 KB
testcase_25 AC 33 ms
8,628 KB
testcase_26 AC 523 ms
17,072 KB
testcase_27 AC 668 ms
19,400 KB
testcase_28 AC 16 ms
7,820 KB
testcase_29 AC 16 ms
7,868 KB
testcase_30 AC 264 ms
19,844 KB
testcase_31 AC 261 ms
19,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())

mod=998244353

U=[]
F=[]
W=[]
P=[]

for i in range(N):
    x,y=input().split()
    y=int(y)

    if x=="U":
        U.append(y)
    elif x=="F":
        F.append(y)
    elif x=="W":
        W.append(y)
    else:
        P.append(y)
        
c=(N-2)*pow(N-1,mod-2,mod)%mod

ux=0
for a in U:
    ux+=1-pow(c,a,mod)
    ux%=mod

fx=0
for a in F:
    fx+=1-pow(c,a,mod)
    fx%=mod

wx=0
for a in W:
    wx+=1-pow(c,a,mod)
    wx%=mod

SUM=sum(U)+sum(F)+sum(W)+sum(P)

ANS2=ux*fx*wx*pow(N-1,SUM,mod)%mod

print(ANS2*len(P)%mod)
0