結果

問題 No.1927 AB-CD
ユーザー ksukegamesksukegames
提出日時 2023-03-25 13:33:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 933 bytes
コンパイル時間 5,956 ms
コンパイル使用メモリ 317,396 KB
実行使用メモリ 6,268 KB
最終ジャッジ日時 2023-10-19 00:30:32
合計ジャッジ時間 8,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 14 ms
5,620 KB
testcase_05 AC 13 ms
5,356 KB
testcase_06 AC 13 ms
5,356 KB
testcase_07 AC 11 ms
5,092 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 14 ms
5,620 KB
testcase_10 AC 11 ms
5,092 KB
testcase_11 AC 12 ms
5,356 KB
testcase_12 AC 6 ms
4,440 KB
testcase_13 AC 8 ms
4,440 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 13 ms
5,356 KB
testcase_17 AC 10 ms
4,828 KB
testcase_18 AC 10 ms
5,092 KB
testcase_19 AC 11 ms
5,092 KB
testcase_20 AC 15 ms
5,740 KB
testcase_21 AC 11 ms
5,092 KB
testcase_22 AC 6 ms
4,348 KB
testcase_23 AC 16 ms
6,004 KB
testcase_24 AC 17 ms
6,268 KB
testcase_25 AC 17 ms
6,268 KB
testcase_26 AC 17 ms
6,268 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)
#define coutf(f) cout << fixed << setprecision(f)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

using mint = modint998244353;
const int mod = 998244353;

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

int main() {
	int n;
	string s;
	cin >> n >> s;
	map<char, int> mp;
	rep(i, n) mp[s[i]]++;
	combination c(n);
	mint ans = c(n, mp['A'] + mp['B']);
	cout << ans.val() << endl;
	return 0;
}
0