結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー titiatitia
提出日時 2023-06-20 08:04:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 20,484 KB
最終ジャッジ日時 2023-09-10 03:09:05
合計ジャッジ時間 17,128 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,956 KB
testcase_01 AC 16 ms
7,832 KB
testcase_02 AC 17 ms
7,744 KB
testcase_03 AC 17 ms
7,740 KB
testcase_04 WA -
testcase_05 AC 17 ms
7,808 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 16 ms
7,860 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 33 ms
8,512 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 16 ms
7,864 KB
testcase_29 AC 16 ms
7,832 KB
testcase_30 AC 264 ms
20,016 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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)
SUM%=mod

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

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