結果

問題 No.3395 Range Flipping Game
コンテスト
ユーザー hiromi_ayase
提出日時 2025-12-06 19:17:27
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 1,149 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,457 ms
コンパイル使用メモリ 335,132 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-12-06 19:17:35
合計ジャッジ時間 7,843 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 18 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define FAST_IO                \
  ios::sync_with_stdio(false); \
  cin.tie(0);
const i64 INF = 1001001001001001001;
using Modint = atcoder::static_modint<998244353>;

int main() {
  FAST_IO

  int T;
  cin >> T;
  while (T--) {
    int N;
    string S;
    cin >> N >> S;

    if (N == 1) {
      cout << "B" << endl;
    } else {
      if (S[0] == 'B' && S[1] == 'B') {
        // none
      } else if (S[0] == 'B' && S[1] == 'A') {
        S[1] = 'B';
      } else if (S[0] == 'A' && S[1] == 'A') {
        S[0] = 'B';
        S[1] = 'B';
      } else {
        int s = -1, e = N;
        for (int i = 2; i < N; i ++) {
          if (S[i] == 'B') {
            if (s < 0) {
              s = i;
            }
          }
          if (s >= 0 && S[i] == 'A') {
            e = i;
            break;
          }
        }
        for (int i = s; i < e; i ++) {
          S[i] = 'A';
        }
        S[0] = 'B';
      }
      cout << S << endl;
    }

  }
  //AAAABBBBAAAABBBB
}
0