結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
yel_ow
|
| 提出日時 | 2026-02-15 16:10:41 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,691 bytes |
| 記録 | |
| コンパイル時間 | 3,382 ms |
| コンパイル使用メモリ | 333,860 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-02-15 16:10:48 |
| 合計ジャッジ時間 | 6,732 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 WA * 19 |
ソースコード
//#include <monsterenergy>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
int main()
{
int T; cin >> T;
for(int t = 0; t < T; t++)
{
int N; cin >> N;
string S; cin >> S;
auto solve = [&](int start_idx) {
int cnt_A = 0;
for(int i = start_idx; i < N; i++) {
if(S[i] == 'A') cnt_A++;
else break;
}
if(cnt_A >= 3) {
if(start_idx + 1 < N) S[start_idx + 1] = 'B';
} else {
bool flag = false;
bool active = false;
for(int i = start_idx; i < N; i++) {
if(S[i] == 'B') {
if(!flag) {
flag = true;
} else {
S[i] = 'A';
active = true;
}
} else {
if(active) break;
}
}
}
};
if(S[0] == 'A') {
solve(0);
} else {
// Check for leading Bs
int cnt_B = 0;
for(int i = 0; i < N; i++) {
if(S[i] == 'B') cnt_B++;
else break;
}
if(cnt_B == 1) {
if(N > 1 && S[1] == 'A') {
solve(1);
}
}
}
S[0] = 'B';
cout << S << endl;
}
return 0;
}
yel_ow