結果

問題 No.2356 Back Door Tour in Four Seasons
ユーザー mkawa2mkawa2
提出日時 2023-06-18 16:01:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 1,279 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 93,096 KB
最終ジャッジ日時 2023-09-08 12:03:18
合計ジャッジ時間 14,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,472 KB
testcase_01 AC 73 ms
71,116 KB
testcase_02 AC 71 ms
71,492 KB
testcase_03 AC 73 ms
71,348 KB
testcase_04 AC 431 ms
92,268 KB
testcase_05 AC 73 ms
71,440 KB
testcase_06 AC 72 ms
71,100 KB
testcase_07 AC 73 ms
71,260 KB
testcase_08 AC 491 ms
92,068 KB
testcase_09 AC 547 ms
93,096 KB
testcase_10 AC 544 ms
92,916 KB
testcase_11 AC 543 ms
92,936 KB
testcase_12 AC 553 ms
92,776 KB
testcase_13 AC 548 ms
92,892 KB
testcase_14 AC 552 ms
93,048 KB
testcase_15 AC 316 ms
83,144 KB
testcase_16 AC 509 ms
90,300 KB
testcase_17 AC 513 ms
90,508 KB
testcase_18 AC 496 ms
90,492 KB
testcase_19 AC 312 ms
83,532 KB
testcase_20 AC 495 ms
90,272 KB
testcase_21 AC 416 ms
86,688 KB
testcase_22 AC 309 ms
83,340 KB
testcase_23 AC 248 ms
81,308 KB
testcase_24 AC 516 ms
90,292 KB
testcase_25 AC 100 ms
76,992 KB
testcase_26 AC 413 ms
86,792 KB
testcase_27 AC 511 ms
90,444 KB
testcase_28 AC 73 ms
71,608 KB
testcase_29 AC 72 ms
71,540 KB
testcase_30 AC 169 ms
91,368 KB
testcase_31 AC 170 ms
91,204 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"
cc = [0]*4
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

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

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