結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
Cafe1942
|
| 提出日時 | 2025-12-02 00:55:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 2,533 bytes |
| コンパイル時間 | 980 ms |
| コンパイル使用メモリ | 113,516 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-12-02 00:55:39 |
| 合計ジャッジ時間 | 3,279 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
#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";
}
else 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") {
cout << S << "\n";
}
}
}
}
Cafe1942