Submission #73695365
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main() {
string S, T; cin >> S >> T;
string sna, tna;
vector<int> sap, tap;
for (char c : S) {
if (c == 'A') {
sap.push_back(sna.size());
} else {
sna += c;
}
}
for (char c : T) {
if (c == 'A') {
tap.push_back(tna.size());
} else {
tna += c;
}
}
if (sna != tna) {
cout << -1 << endl;
return 0;
}
int i = 0, j = 0;
int res = 0;
int n = sap.size(), m = tap.size();
while (i < n && j < m) {
if (sap[i] < tap[j]) {
res++;
i++;
} else if (sap[i] > tap[j]) {
res++;
j++;
} else {
i++;
j++;
}
}
res += (n - i) + (m - j);
cout << res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Insert and Erase A |
| User | a_legend_cat |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 968 Byte |
| Status | AC |
| Exec Time | 12 ms |
| Memory | 8216 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt, 04_handmade_08.txt, 04_handmade_09.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3448 KiB |
| 00_sample_01.txt | AC | 1 ms | 3588 KiB |
| 00_sample_02.txt | AC | 1 ms | 3600 KiB |
| 00_sample_03.txt | AC | 1 ms | 3592 KiB |
| 01_random_00.txt | AC | 3 ms | 3912 KiB |
| 01_random_01.txt | AC | 4 ms | 3976 KiB |
| 01_random_02.txt | AC | 9 ms | 5092 KiB |
| 02_random2_00.txt | AC | 6 ms | 4376 KiB |
| 02_random2_01.txt | AC | 12 ms | 8064 KiB |
| 02_random2_02.txt | AC | 10 ms | 5396 KiB |
| 02_random2_03.txt | AC | 11 ms | 5616 KiB |
| 02_random2_04.txt | AC | 8 ms | 5532 KiB |
| 02_random2_05.txt | AC | 7 ms | 5244 KiB |
| 02_random2_06.txt | AC | 9 ms | 4940 KiB |
| 02_random2_07.txt | AC | 7 ms | 6020 KiB |
| 02_random2_08.txt | AC | 11 ms | 6632 KiB |
| 02_random2_09.txt | AC | 12 ms | 6352 KiB |
| 02_random2_10.txt | AC | 8 ms | 4624 KiB |
| 02_random2_11.txt | AC | 9 ms | 5112 KiB |
| 03_random3_00.txt | AC | 9 ms | 5116 KiB |
| 03_random3_01.txt | AC | 8 ms | 5228 KiB |
| 03_random3_02.txt | AC | 8 ms | 4940 KiB |
| 03_random3_03.txt | AC | 10 ms | 5964 KiB |
| 04_handmade_00.txt | AC | 1 ms | 3452 KiB |
| 04_handmade_01.txt | AC | 1 ms | 3572 KiB |
| 04_handmade_02.txt | AC | 1 ms | 3572 KiB |
| 04_handmade_03.txt | AC | 1 ms | 3496 KiB |
| 04_handmade_04.txt | AC | 9 ms | 4924 KiB |
| 04_handmade_05.txt | AC | 10 ms | 6748 KiB |
| 04_handmade_06.txt | AC | 10 ms | 6340 KiB |
| 04_handmade_07.txt | AC | 11 ms | 8216 KiB |
| 04_handmade_08.txt | AC | 6 ms | 6032 KiB |
| 04_handmade_09.txt | AC | 6 ms | 5976 KiB |