結果
| 問題 | No.1927 AB-CD |
| コンテスト | |
| ユーザー |
Iroha_3856
|
| 提出日時 | 2026-01-11 13:48:06 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 803 bytes |
| 記録 | |
| コンパイル時間 | 3,223 ms |
| コンパイル使用メモリ | 339,668 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2026-01-11 13:48:11 |
| 合計ジャッジ時間 | 4,549 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint998244353;
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define siz(x) (int)x.size()
const int inf = 1e9;
const ll INF = 4e18;
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main() {
int N; string S; cin >> N >> S;
int a = 0, c = 0;
for (char x : S) {
if (x == 'A' or x == 'B') a++;
else c++;
}
mint ans = 1;
rep(i, 1, a + c + 1) ans *= i;
rep(i, 1, a + 1) ans /= i;
rep(i, 1, c + 1) ans /= i;
cout << ans.val() << endl;
}
Iroha_3856