結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー mkawa2mkawa2
提出日時 2023-06-18 15:44:45
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,236 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 86,668 KB
実行使用メモリ 97,144 KB
最終ジャッジ日時 2023-09-08 11:45:16
合計ジャッジ時間 13,474 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,956 KB
testcase_01 AC 72 ms
70,716 KB
testcase_02 AC 73 ms
70,912 KB
testcase_03 AC 74 ms
71,008 KB
testcase_04 AC 438 ms
95,772 KB
testcase_05 AC 72 ms
71,096 KB
testcase_06 AC 72 ms
70,836 KB
testcase_07 AC 73 ms
70,900 KB
testcase_08 AC 496 ms
96,044 KB
testcase_09 AC 553 ms
96,572 KB
testcase_10 AC 551 ms
96,528 KB
testcase_11 AC 546 ms
96,996 KB
testcase_12 AC 562 ms
96,420 KB
testcase_13 AC 558 ms
97,144 KB
testcase_14 AC 558 ms
97,024 KB
testcase_15 AC 324 ms
85,100 KB
testcase_16 AC 509 ms
94,156 KB
testcase_17 AC 521 ms
94,276 KB
testcase_18 AC 504 ms
94,368 KB
testcase_19 AC 319 ms
85,224 KB
testcase_20 AC 499 ms
93,800 KB
testcase_21 AC 421 ms
89,904 KB
testcase_22 AC 315 ms
85,588 KB
testcase_23 AC 251 ms
82,176 KB
testcase_24 AC 518 ms
94,424 KB
testcase_25 AC 102 ms
76,472 KB
testcase_26 AC 417 ms
89,540 KB
testcase_27 AC 516 ms
94,208 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 171 ms
95,824 KB
testcase_31 AC 170 ms
95,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# md = 10**9+7
md = 998244353

n = II()
ii = [[] for _ in range(4)]
aa = [0]*n
t = "UFWP"
dp = [0]*n
cc = [0]*n
for i in range(n):
    s, a = SI().split()
    s = t.find(s)
    ii[s].append(i)
    a = int(a)
    aa[i] = a
    cc[s] += a
    if s == 0: dp[i] = 1

tot = [0]*4+[1]
for s in range(3):
    for i in ii[s]:
        a=aa[i]
        dp[i] = (pow(n-1, a, md)-pow(n-2, a, md))*pow(n-1, cc[s]-a, md)%md*tot[s-1]%md
        tot[s] += dp[i]
        tot[s] %= md

ans=tot[2]*pow(n-1,cc[3],md)%md*len(ii[3])%md
print(ans)
0