結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-02 17:53:53 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,366 bytes |
| コンパイル時間 | 3,299 ms |
| コンパイル使用メモリ | 279,036 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-02 17:53:59 |
| 合計ジャッジ時間 | 5,771 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = (ll)s; i < (ll)(t); i++)
#define rrep(i, s, t) for (ll i = (ll)(t) - 1; i >= (ll)(s); i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define TT template <typename T>
template <class T1, class T2>
bool chmin(T1& x, T2 y) { return x > y ? (x = y, true) : false; }
template <class T1, class T2>
bool chmax(T1& x, T2 y) { return x < y ? (x = y, true) : false; }
struct io_setup {
io_setup() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cout << fixed << setprecision(15);
srand(time(NULL));
}
} io_setup;
void solve() {
int N;
string S;
cin >> N >> S;
int l = 0;
while (l < N && S[l] == 'B') l++;
if (l == N) {
cout << S << endl;
return;
}
int r = l;
while (r < N && S[r] == 'A') r++;
if (l >= 2) {
cout << S << endl;
} else if (r - l >= 3) {
rep(i, l, l + 2) S[i] = 'B';
cout << S << endl;
} else {
int n = r + 1;
while (n < N && S[n] == 'A') n++;
while (n < N && S[n] == 'B') {
S[n] = 'A';
n++;
}
rep(i, l, r) S[i] = 'B';
cout << S << endl;
}
}
int main() {
int T;
cin >> T;
while (T--) {
solve();
}
}