結果
| 問題 | No.3395 Range Flipping Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-02 16:53:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 2,000 ms |
| コード長 | 1,167 bytes |
| コンパイル時間 | 2,207 ms |
| コンパイル使用メモリ | 192,764 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-02 16:53:28 |
| 合計ジャッジ時間 | 3,855 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d", &T);
| ~~~~~^~~~~~~~~~
main.cpp:49:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d%s", &n, s + 1);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000010, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];
char s[N];
void solve() {
if (n == 1) {
puts("B");
return;
}
if (s[1] == 'A') {
int i = 1;
if (s[i + 1] == 'B') {
for (int k = i + 2; k < n + 1; k++) {
if (s[k] == 'A') continue;
for (int j = k; j < n + 1; j++)
if (s[j] == 'B') s[j] = 'A';
else break;
break;
}
} else {
s[i + 1] = 'B';
for (int j = i + 2; j < n + 1; j++)
if (s[j] == 'B') s[j] = 'A';
else break;
}
s[1] = 'B';
puts(s + 1);
} else {
if (s[2] == 'A') {
s[2] = 'B';
for (int i = 3; i < n + 1; i++)
if (s[i] == 'B') s[i] = 'A';
else break;
}
puts(s + 1);
}
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
scanf("%d%s", &n, s + 1);
solve();
}
return 0;
}