結果

問題 No.1481 Rotation ABC
ユーザー chineristACchineristAC
提出日時 2021-03-08 22:03:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 974 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 67,968 KB
最終ジャッジ日時 2024-04-18 18:15:37
合計ジャッジ時間 4,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
67,328 KB
testcase_01 AC 66 ms
66,888 KB
testcase_02 AC 62 ms
67,072 KB
testcase_03 AC 66 ms
67,072 KB
testcase_04 AC 61 ms
67,328 KB
testcase_05 AC 61 ms
67,328 KB
testcase_06 AC 62 ms
66,816 KB
testcase_07 AC 62 ms
66,944 KB
testcase_08 AC 61 ms
67,200 KB
testcase_09 AC 62 ms
66,944 KB
testcase_10 AC 64 ms
66,816 KB
testcase_11 AC 62 ms
66,944 KB
testcase_12 AC 62 ms
67,072 KB
testcase_13 AC 61 ms
67,712 KB
testcase_14 AC 62 ms
67,712 KB
testcase_15 AC 61 ms
67,612 KB
testcase_16 AC 61 ms
67,328 KB
testcase_17 AC 61 ms
67,328 KB
testcase_18 AC 64 ms
67,584 KB
testcase_19 AC 62 ms
67,328 KB
testcase_20 AC 63 ms
67,200 KB
testcase_21 AC 62 ms
67,584 KB
testcase_22 AC 61 ms
67,220 KB
testcase_23 AC 62 ms
67,712 KB
testcase_24 AC 64 ms
67,584 KB
testcase_25 AC 64 ms
67,712 KB
testcase_26 AC 64 ms
67,584 KB
testcase_27 AC 62 ms
67,760 KB
testcase_28 AC 63 ms
67,840 KB
testcase_29 AC 62 ms
67,840 KB
testcase_30 AC 63 ms
67,456 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def cmb(n, r, mod):#コンビネーションの高速計算 
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 2*10**5
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

N = int(input())
S = input().rstrip()
a = S.count("A")
b = S.count("B")
c = S.count("C")
if a*b*c:
    res = g1[N]*g2[a]*g2[b]*g2[c]-N
    print(res % mod)
else:
    print(1)
0