提出 #29759211
ソースコード 拡げる
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
// using P = pair<ll,ll>;
using P = pair<int,int>;
using vint = vector<int>;
using vll = vector<ll>;
using vvint = vector<vector<int>>;
using vvll = vector<vector<ll>>;
// const ll INF = (ll)2e18+9;
const int INF = (int)2e9+7;
// const ll MOD = (ll)1e9+9;
template<typename T>
void chmin(T &a, T b) { a = min(a, b); }
template<typename T>
void chmax(T &a, T b) { a = max(a, b); }
template<typename T>
void print(vector<T> v) {
int n = v.size();
rep(i,n) {
if (i == 0) cout << v[i];
else cout << ' ' << v[i];
}
cout << endl;
}
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int cur = 0;
string ans = "";
while (cur < n) {
if (s[cur] != 'A' && s[cur] != 'B') {
ans.push_back(s[cur]);
cur++;
continue;
}
int numa = 0, numb = 0;
while (cur < n && (s[cur] == 'A' || s[cur] == 'B')) {
numa += s[cur] == 'A';
numb += s[cur] == 'B';
cur++;
}
numa += numb / 2;
numb %= 2;
ans += string(numa, 'A');
ans += string(numb, 'B');
}
cout << ans << endl;
}
int main() {
solve();
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - A ↔ BB |
| ユーザ | goropikari |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 300 |
| コード長 | 1641 Byte |
| 結果 | AC |
| 実行時間 | 13 ms |
| メモリ | 3888 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-001.txt | AC | 10 ms | 3576 KiB |
| 00-sample-002.txt | AC | 2 ms | 3560 KiB |
| 00-sample-003.txt | AC | 2 ms | 3528 KiB |
| 01-001.txt | AC | 2 ms | 3564 KiB |
| 01-002.txt | AC | 2 ms | 3452 KiB |
| 01-003.txt | AC | 7 ms | 3500 KiB |
| 01-004.txt | AC | 3 ms | 3576 KiB |
| 01-005.txt | AC | 3 ms | 3660 KiB |
| 01-006.txt | AC | 9 ms | 3876 KiB |
| 01-007.txt | AC | 8 ms | 3812 KiB |
| 01-008.txt | AC | 13 ms | 3816 KiB |
| 01-009.txt | AC | 8 ms | 3516 KiB |
| 01-010.txt | AC | 11 ms | 3720 KiB |
| 01-011.txt | AC | 11 ms | 3724 KiB |
| 01-012.txt | AC | 10 ms | 3888 KiB |
| 01-013.txt | AC | 11 ms | 3576 KiB |
| 01-014.txt | AC | 12 ms | 3712 KiB |