結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
hiromi_ayase
|
| 提出日時 | 2025-12-06 19:10:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,150 bytes |
| 記録 | |
| コンパイル時間 | 5,804 ms |
| コンパイル使用メモリ | 334,952 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-06 19:10:26 |
| 合計ジャッジ時間 | 9,155 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 20 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO \
ios::sync_with_stdio(false); \
cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;
int main() {
FAST_IO
int T;
cin >> T;
while (T--) {
int N;
string S;
cin >> N >> S;
if (N == 1) {
cout << "B" << endl;
} else {
if (S[0] == 'B' && S[1] == 'B') {
// none
} else if (S[0] == 'B' && S[1] == 'A') {
S[1] = 'B';
} else if (S[0] == 'A' && S[1] == 'A') {
S[0] = 'B';
S[1] = 'B';
} else {
int s = -1, e = -1;
for (int i = 2; i < N; i ++) {
if (S[i] == 'B') {
if (s < 0) {
s = i;
}
}
if (s >= 0 && S[i] == 'A') {
e = i;
break;
}
}
for (int i = s; i < e; i ++) {
S[i] = 'A';
}
S[0] = 'B';
}
cout << S << endl;
}
}
//AAAABBBBAAAABBBB
}
hiromi_ayase