結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-02 12:52:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 715 bytes |
| コンパイル時間 | 635 ms |
| コンパイル使用メモリ | 65,044 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-02 12:52:16 |
| 合計ジャッジ時間 | 2,944 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
int N;
string S;
cin>>N>>S;
const char flip='A'^'B';
if(N<=2);
else
{
if(S[0]=='A')
{
if(S[1]=='A')
{
S[1]^=flip;
for(int j=2;j<N&&S[j]=='B';j++)S[j]^=flip;
}
else
{
int j=2;
while(j<N&&S[j]=='A')j++;
for(;j<N&&S[j]=='B';j++)S[j]^=flip;
}
}
else
{
if(S[1]=='B')S[0]^=flip;
else
{
S[0]^=flip;
S[1]^=flip;
for(int j=2;j<N&&S[j]=='B';j++)S[j]^=flip;
}
}
}
int i=0;
while(i<N&&S[i]=='B')i++;
for(;i<N&&S[i]=='A';i++)S[i]^=flip;
cout<<S<<"\n";
}
}