結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-06-16 23:06:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 545 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 1,826 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 88,872 KB
最終ジャッジ日時 2023-09-06 21:56:51
合計ジャッジ時間 13,247 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,208 KB
testcase_01 AC 75 ms
71,028 KB
testcase_02 AC 77 ms
71,480 KB
testcase_03 AC 74 ms
71,432 KB
testcase_04 AC 435 ms
87,720 KB
testcase_05 AC 83 ms
71,228 KB
testcase_06 AC 74 ms
71,216 KB
testcase_07 AC 75 ms
70,992 KB
testcase_08 AC 501 ms
88,504 KB
testcase_09 AC 535 ms
88,756 KB
testcase_10 AC 530 ms
88,580 KB
testcase_11 AC 527 ms
88,872 KB
testcase_12 AC 536 ms
88,768 KB
testcase_13 AC 535 ms
88,716 KB
testcase_14 AC 545 ms
88,632 KB
testcase_15 AC 308 ms
82,024 KB
testcase_16 AC 493 ms
86,056 KB
testcase_17 AC 501 ms
86,500 KB
testcase_18 AC 483 ms
86,276 KB
testcase_19 AC 314 ms
82,464 KB
testcase_20 AC 486 ms
86,268 KB
testcase_21 AC 420 ms
84,432 KB
testcase_22 AC 307 ms
82,168 KB
testcase_23 AC 247 ms
81,348 KB
testcase_24 AC 503 ms
86,380 KB
testcase_25 AC 102 ms
76,636 KB
testcase_26 AC 404 ms
84,672 KB
testcase_27 AC 498 ms
86,428 KB
testcase_28 AC 74 ms
71,340 KB
testcase_29 AC 86 ms
71,120 KB
testcase_30 AC 165 ms
88,564 KB
testcase_31 AC 156 ms
88,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
import math
import heapq

N = int(stdin.readline())

SA = [ [] for i in range(4) ]

for i in range(N):

    S,A = stdin.readline().split()
    A = int(A)

    if S == "U":
        SA[0].append(A)
    if S == "F":
        SA[1].append(A)
    if S == "W":
        SA[2].append(A)
    if S == "P":
        SA[3].append(A)

mod = 998244353

if [] in SA:
    print (0)
    sys.exit()

ans = 1

for i in range(3):

    now = 0
    nex_size = len(SA[i+1])

    rema = sum(SA[i])
    for a in SA[i]:
        patt = pow(N-1,a,mod) - pow(N-2,a,mod)
        now += patt * pow(N-1,rema-a,mod)
        now %= mod
    ans *= now
    ans %= mod

    #print (now)

ans *= len(SA[-1])
ans *= pow(N-1,sum(SA[-1]),mod)
print (ans % mod)


    
0