提出 #73685357
ソースコード 拡げる
#include<bits/stdc++.h>
#include"atcoder/all"
using namespace std;
using namespace atcoder;
//#define int long
//int inf = 2000000000000000000;
signed main(){
string s,t;cin>>s>>t;
int i=0,j=0;
int sa=0,ta=0;
string S,T;
for(int k=0;k<s.size();k++){
if(s[k]!='A')S+=s[k];
}
for(int k=0;k<t.size();k++){
if(t[k]!='A')T+=t[k];
}
if(S!=T){
cout<<"-1\n";return(0);
}
int ans=0;
for(int k=0;k<S.size();k++){
while(i<s.size()&&s[i]=='A'){
sa++;
i++;
}
while(j<t.size()&&t[j]=='A'){
ta++;
j++;
}
ans+=abs(sa-ta);
sa=0,ta=0;
i++;j++;
//cout<<ans<<" "<<i<<" "<<j<<"\n";
}
ans+=abs(((int)s.size()-i)-((int)t.size()-j));
cout<<ans<<"\n";
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Insert and Erase A |
| ユーザ | Sabakanmelm |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 300 |
| コード長 | 863 Byte |
| 結果 | AC |
| 実行時間 | 13 ms |
| メモリ | 4964 KiB |
コンパイルエラー
./Main.cpp: In function 'int main()':
./Main.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for(int k=0;k<s.size();k++){
| ~^~~~~~~~~
./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 | for(int k=0;k<t.size();k++){
| ~^~~~~~~~~
./Main.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int k=0;k<S.size();k++){
| ~^~~~~~~~~
./Main.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | while(i<s.size()&&s[i]=='A'){
| ~^~~~~~~~~
./Main.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | while(j<t.size()&&t[j]=='A'){
| ~^~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3604 KiB |
| 00_sample_01.txt | AC | 1 ms | 3604 KiB |
| 00_sample_02.txt | AC | 1 ms | 3424 KiB |
| 00_sample_03.txt | AC | 1 ms | 3576 KiB |
| 01_random_00.txt | AC | 3 ms | 3816 KiB |
| 01_random_01.txt | AC | 4 ms | 4048 KiB |
| 01_random_02.txt | AC | 10 ms | 4848 KiB |
| 02_random2_00.txt | AC | 7 ms | 4248 KiB |
| 02_random2_01.txt | AC | 10 ms | 4340 KiB |
| 02_random2_02.txt | AC | 12 ms | 4856 KiB |
| 02_random2_03.txt | AC | 13 ms | 4696 KiB |
| 02_random2_04.txt | AC | 10 ms | 4252 KiB |
| 02_random2_05.txt | AC | 7 ms | 4056 KiB |
| 02_random2_06.txt | AC | 10 ms | 4512 KiB |
| 02_random2_07.txt | AC | 7 ms | 3936 KiB |
| 02_random2_08.txt | AC | 11 ms | 4128 KiB |
| 02_random2_09.txt | AC | 12 ms | 4252 KiB |
| 02_random2_10.txt | AC | 9 ms | 4508 KiB |
| 02_random2_11.txt | AC | 11 ms | 4760 KiB |
| 03_random3_00.txt | AC | 10 ms | 4844 KiB |
| 03_random3_01.txt | AC | 8 ms | 4184 KiB |
| 03_random3_02.txt | AC | 8 ms | 4516 KiB |
| 03_random3_03.txt | AC | 10 ms | 4304 KiB |
| 04_handmade_00.txt | AC | 1 ms | 3584 KiB |
| 04_handmade_01.txt | AC | 1 ms | 3424 KiB |
| 04_handmade_02.txt | AC | 1 ms | 3452 KiB |
| 04_handmade_03.txt | AC | 1 ms | 3592 KiB |
| 04_handmade_04.txt | AC | 10 ms | 4964 KiB |
| 04_handmade_05.txt | AC | 9 ms | 4696 KiB |
| 04_handmade_06.txt | AC | 9 ms | 4680 KiB |
| 04_handmade_07.txt | AC | 9 ms | 4428 KiB |
| 04_handmade_08.txt | AC | 5 ms | 3920 KiB |
| 04_handmade_09.txt | AC | 5 ms | 3948 KiB |