Submission #29740436
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define SET(a) memset(a, -1, sizeof a)
#define R(i, a, b) for (int i = (a); i < (b); ++i)
#define L(i, a, b) for (int i = (b) - 1; i >= (a); --i)
using i64 = long long;
constexpr int xn = 200001;
int n, m;
char s[xn], t[xn];
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> n >> s;
array<int, 2> cnt = {0, 0};
R(i, 0, n) {
if (s[i] == 'C') {
R(j, 0, cnt[0] + cnt[1] / 2) t[m++] = 'A';
if (cnt[1] & 1) t[m++] = 'B'; t[m++] = 'C'; cnt[0] = cnt[1] = 0;
} else cnt[s[i] - 'A'] += 1;
}
R(j, 0, cnt[0] + cnt[1] / 2) t[m++] = 'A';
if (cnt[1] & 1) t[m++] = 'B';
cout << t << '\n';
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - A ↔ BB |
| User | LMENSHKORG |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 708 Byte |
| Status | AC |
| Exec Time | 7 ms |
| Memory | 4024 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:19:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
19 | if (cnt[1] & 1) t[m++] = 'B'; t[m++] = 'C'; cnt[0] = cnt[1] = 0;
| ^~
./Main.cpp:19:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
19 | if (cnt[1] & 1) t[m++] = 'B'; t[m++] = 'C'; cnt[0] = cnt[1] = 0;
| ^
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3560 KiB |
| 00-sample-002.txt | AC | 2 ms | 3564 KiB |
| 00-sample-003.txt | AC | 2 ms | 3508 KiB |
| 01-001.txt | AC | 2 ms | 3508 KiB |
| 01-002.txt | AC | 2 ms | 3508 KiB |
| 01-003.txt | AC | 3 ms | 3804 KiB |
| 01-004.txt | AC | 7 ms | 3636 KiB |
| 01-005.txt | AC | 2 ms | 3712 KiB |
| 01-006.txt | AC | 5 ms | 4024 KiB |
| 01-007.txt | AC | 5 ms | 3944 KiB |
| 01-008.txt | AC | 6 ms | 3880 KiB |
| 01-009.txt | AC | 3 ms | 3788 KiB |
| 01-010.txt | AC | 4 ms | 3872 KiB |
| 01-011.txt | AC | 5 ms | 3820 KiB |
| 01-012.txt | AC | 6 ms | 3932 KiB |
| 01-013.txt | AC | 5 ms | 3872 KiB |
| 01-014.txt | AC | 5 ms | 3944 KiB |