Submission #73710052
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6 + 5;
int main()
{
string s, t;
cin >> s >> t;
int i = 0, j = 0, sa = 0, ta = 0, ans = 0;
while (1)
{
while (i < s.size() && s[i] == 'A')
sa++, i++;
while (j < t.size() && t[j] == 'A')
ta++, j++;
if (s[i] != t[j])
{
cout << -1 << endl;
return 0;
}
if (i == s.size() || j == t.size())
break;
ans += abs(sa - ta);
i++, j++;
sa = 0, ta = 0;
}
cout << ans + abs(sa - ta) << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Insert and Erase A |
| User | altman_xie |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 667 Byte |
| Status | AC |
| Exec Time | 10 ms |
| Memory | 4508 KiB |
Compile Error
./Main.cpp: In function 'int main()':
./Main.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | while (i < s.size() && s[i] == 'A')
| ~~^~~~~~~~~~
./Main.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | while (j < t.size() && t[j] == 'A')
| ~~^~~~~~~~~~
./Main.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if (i == s.size() || j == t.size())
| ~~^~~~~~~~~~~
./Main.cpp:22:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | if (i == s.size() || j == t.size())
| ~~^~~~~~~~~~~
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 | 3516 KiB |
| 00_sample_01.txt | AC | 1 ms | 3408 KiB |
| 00_sample_02.txt | AC | 1 ms | 3524 KiB |
| 00_sample_03.txt | AC | 1 ms | 3524 KiB |
| 01_random_00.txt | AC | 3 ms | 3816 KiB |
| 01_random_01.txt | AC | 4 ms | 3896 KiB |
| 01_random_02.txt | AC | 8 ms | 4508 KiB |
| 02_random2_00.txt | AC | 6 ms | 4016 KiB |
| 02_random2_01.txt | AC | 9 ms | 4496 KiB |
| 02_random2_02.txt | AC | 9 ms | 4500 KiB |
| 02_random2_03.txt | AC | 10 ms | 4488 KiB |
| 02_random2_04.txt | AC | 8 ms | 4072 KiB |
| 02_random2_05.txt | AC | 6 ms | 4052 KiB |
| 02_random2_06.txt | AC | 8 ms | 4068 KiB |
| 02_random2_07.txt | AC | 6 ms | 3988 KiB |
| 02_random2_08.txt | AC | 9 ms | 4204 KiB |
| 02_random2_09.txt | AC | 10 ms | 4368 KiB |
| 02_random2_10.txt | AC | 7 ms | 4172 KiB |
| 02_random2_11.txt | AC | 9 ms | 4280 KiB |
| 03_random3_00.txt | AC | 8 ms | 4368 KiB |
| 03_random3_01.txt | AC | 8 ms | 4108 KiB |
| 03_random3_02.txt | AC | 8 ms | 4296 KiB |
| 03_random3_03.txt | AC | 7 ms | 4252 KiB |
| 04_handmade_00.txt | AC | 1 ms | 3452 KiB |
| 04_handmade_01.txt | AC | 1 ms | 3556 KiB |
| 04_handmade_02.txt | AC | 1 ms | 3592 KiB |
| 04_handmade_03.txt | AC | 1 ms | 3556 KiB |
| 04_handmade_04.txt | AC | 9 ms | 4480 KiB |
| 04_handmade_05.txt | AC | 8 ms | 4388 KiB |
| 04_handmade_06.txt | AC | 8 ms | 4392 KiB |
| 04_handmade_07.txt | AC | 8 ms | 4492 KiB |
| 04_handmade_08.txt | AC | 5 ms | 4016 KiB |
| 04_handmade_09.txt | AC | 5 ms | 4016 KiB |