結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2025-12-02 00:41:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 1,217 bytes |
| コンパイル時間 | 594 ms |
| コンパイル使用メモリ | 75,436 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-02 00:41:10 |
| 合計ジャッジ時間 | 2,399 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll INF = 1ll << 60;
#define REP(i,n) for(ll i=0; i<ll(n); i++)
template <class T> using V = vector<T>;
template <class A, class B> void chmax(A& l, const B& r){ if(l < r) l = r; }
template <class A, class B> void chmin(A& l, const B& r){ if(r < l) l = r; }
void testcase(){
ll N; cin >> N;
string S; cin >> S;
if(N == 1){
cout << "B\n";
}
else if(S[0] == 'B' && S[1] == 'B'){
cout << S << "\n";
}
else if(S[0] == 'B' && S[1] == 'A'){
S[1] = 'B';
for(ll p=2; p<N && S[p] == 'B'; p++) S[p] = 'A';
cout << S << "\n";
}
else if(S[0] == 'A' && S[1] == 'B'){
S[0] = 'B';
ll p = 2;
while(p < N && S[p] == 'A') p++;
while(p < N && S[p] == 'B') S[p++] = 'A';
cout << S << "\n";
}
else {
S[0] = S[1] = 'B';
for(ll p=2; p<N && S[p] == 'B'; p++) S[p] = 'A';
cout << S << "\n";
}
}
int main(){
cin.tie(0)->sync_with_stdio(0);
ll T; cin >> T;
REP(t,T)
testcase();
return 0;
}
Nachia