結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
Cafe1942
|
| 提出日時 | 2025-12-02 00:49:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,897 bytes |
| コンパイル時間 | 1,115 ms |
| コンパイル使用メモリ | 117,020 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-02 00:50:02 |
| 合計ジャッジ時間 | 3,241 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 5 WA * 25 |
ソースコード
#include <iostream>
#include <iomanip>//小数点出力用
//cout << fixed << setprecision(10) << ans;
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
using namespace std;
#define modPHash (ll)((1LL<<61)-1)
#define modP (ll)998244353
bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); }
int clk4(int num) { return (num - 2) * (num % 2); }
void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); }
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int N;
cin >> N;
string S;
cin >> S;
if (N == 1) {
cout << "B\n";
}
else if(N == 2){
cout << "BB\n";
}
else {
if (S.substr(0,3) == "AAA") {
cout << "BBA";
cout << S.substr(3) << "\n";
}
else if (S.substr(0, 3) == "AAB") {
int i = 2;
while (i != N && S[i] == 'B') {
S[i] = 'A';
i++;
}
S[0] = 'B';
S[1] = 'B';
cout << S << "\n";
}
else if (S.substr(0, 3) == "ABA") {
int i = 2;
while (i != N && S[i] == 'A')i++;
while (i != N && S[i] == 'B') {
S[i] = 'A';
i++;
}
S[0] = 'B';
cout << S << "\n";
}
else if (S.substr(0, 3) == "ABB") {
int i = 2;
while (i != N && S[i] == 'B') {
S[i] = 'A';
i++;
}
S[0] = 'B';
cout << S << "\n";
}
if (S.substr(0, 3) == "BAA") {
cout << "BB";
cout << S.substr(2) << "\n";
}
else if (S.substr(0, 3) == "BAB") {
int i = 2;
while (i != N && S[i] == 'B') {
S[i] = 'A';
i++;
}
S[0] = 'B';
S[1] = 'B';
cout << S << "\n";
}
else if (S.substr(0, 3) == "BBA") {
cout << S << "\n";
}
else if (S.substr(0, 3) == "BBB") {
vector<int>V;
int combo = 3;
char now = 'B';
for (int i = 3;i <= N;i++) {
if (S[i] == now) {
combo++;
}
else {
V.push_back(combo);
now = S[i];
combo = 1;
}
}
if(V.size() <= 2){
cout << S << "\n";
}
else if (V[2] == 1) {
for (int i = 0;i < V.size();i++) {
for (int j = 0;j < V[i];j++) {
if (i % 2 == 1 && i == 4)cout << "A";
else cout << "B";
}
}
}
else {
for (int i = 0;i < V.size();i++) {
for (int j = 0;j < V[i];j++) {
if (i == 2) {
if (j)cout << "A";
else cout << "B";
}
else {
if (i % 2 == 1)cout << "A";
else cout << "B";
}
}
}
}
}
}
}
}
Cafe1942