結果

問題 No.3395 Range Flipping Game
コンテスト
ユーザー daiota
提出日時 2025-12-02 08:49:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 775 bytes
コンパイル時間 1,791 ms
コンパイル使用メモリ 195,884 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-12-02 08:49:50
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i=0;i<ll(n);i++)














int main() {
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	ll i,j;





	int T;
	cin >> T;
	while(T--){

		ll N;
        string S;
		cin >> N >> S;

		if(N==1){
			cout << "B" << endl;
			continue;
		}
		if(N==2){
			cout << "BB" << endl;
			continue;
		}

		string x=S.substr(0,3);

		if(x=="BBB" || x=="BBA"){
			cout << S << endl;

		}

		else if(x=="AAA" || x=="BAA"){
			S[0]='B';
			S[1]='B';
			S[2]='A';
			cout << S << endl;

		}

		else{
			S[0]='B';
			S[1]='B';
			S[2]='A';

			for(i=3;i<N;i++){
				if(S[i]=='B') S[i]='A';
				else break;
			}

			cout << S << endl;

		}





	}








    return 0;
}
0