結果

問題 No.3395 Range Flipping Game
コンテスト
ユーザー tau1235
提出日時 2025-12-02 10:16:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 3,414 ms
コンパイル使用メモリ 278,976 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-02 10:16:10
合計ジャッジ時間 7,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

void solve(){
  int n;
  string s;
  cin>>n>>s;
  string t="ABA";
  t+=string(n,'A');
  int f=0;
  for (int i=0;i<n;i++){
    if (f==0){
      if (s[i]!=t[i]) f=1;
    }
    if (f==1){
      if (s[i]!=t[i]) s[i]=t[i];
      else f=2;
    }
  }
  f=0;
  for (int i=0;i<n;i++){
    if (f==0){
      if (s[i]=='A') f=1;
    }
    if (f==1){
      if (s[i]=='A') s[i]='B';
      else f=2;
    }
  }
  cout<<s<<endl;
}

int main(){
  int t;
  cin>>t;
  while (t--) solve();
}
0