結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-02 00:09:32 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 2,000 ms |
| + 71µs | |
| コード長 | 918 bytes |
| 記録 | |
| コンパイル時間 | 1,966 ms |
| コンパイル使用メモリ | 332,208 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-17 05:30:13 |
| 合計ジャッジ時間 | 4,683 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
using namespace std;
using ll = long long;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string s;
cin >> s;
if(n==1){
cout << "B" << endl;
continue;
}
if(n==2){
cout << "BB" << endl;
continue;
}
if(s.substr(0,2)=="AA" || s.substr(0,2)=="BA"){
for(int i=2;i<n;i++){
if(s[i]=='B')s[i]='A';
else break;
}
}else if(s.substr(0,2)=="AB"){
bool ok=false;
for(int i=2;i<n;i++){
if(s[i]=='B'){
s[i]='A';
ok=true;
}
else if(ok)break;
}
}
s[0]='B';
s[1]='B';
cout << s << endl;
}
return 0;
}