結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
テナガザル
|
| 提出日時 | 2025-12-02 00:08:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 215 ms / 2,000 ms |
| コード長 | 912 bytes |
| コンパイル時間 | 894 ms |
| コンパイル使用メモリ | 102,696 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-02 00:08:43 |
| 合計ジャッジ時間 | 3,538 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
void solve()
{
int n;
cin >> n;
string s;
cin >> s;
if (n == 1)
{
cout << "B" << endl;
return;
}
if (s.substr(0, 2) == "AA")
{
int id = 2;
s[1] = 'B';
while (id < n && s[id] == 'B')
{
s[id] = 'A';
++id;
}
s[0] = 'B';
}
else if (s.substr(0, 2) == "AB")
{
for (int i = 2; i < n; ++i)
{
if (s[i] == 'B')
{
int id = i;
while (id < n && s[id] == 'B')
{
s[id] = 'A';
++id;
}
break;
}
}
s[0] = 'B';
}
else if (s.substr(0, 2) == "BA")
{
int id = 2;
s[1] = 'B';
while (id < n && s[id] == 'B')
{
s[id] = 'A';
++id;
}
s[0] = 'B';
}
cout << s << endl;
}
int main()
{
int t;
cin >> t;
while (t--) solve();
}
テナガザル