Submission #73721682


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main () {
    string s,t;
    int a=0,c=0,f=0,g=0,p=0;
    cin>>s>>t;
    for(int i=a;i<t.size();i++){
        g++;
        if(s[i]!=t[i]&&s[i]!='A'&&t[i]!='A'){f=1;break;}
        else if(s[i]!=t[i]&&t[i]=='A'){
            for(int j=s.size()+1;j>a;j--){
                if(j==a+1)s[j]='A';
                else s[j]=s[j-1];
            }
            c++;
            i=a;
        }
        else if(s[i]!=t[i]){
            for(int j=i;j<s.size();j++){
                s[j]=s[j+1];
            }
            c++;
            i=a;
        }
        if(s[i]==t[i]&&s[i]!='A'){
            a=i;
        }
        if(g==1000000){f=1;break;}
    }
    if(f==1)cout<<-1<<endl;
    else cout<<c<<endl;
}

Submission Info

Submission Time
Task C - Insert and Erase A
User yamasann
Language C++23 (GCC 15.2.0)
Score 0
Code Size 780 Byte
Status WA
Exec Time > 2000 ms
Memory 4548 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=a;i<t.size();i++){
      |                 ~^~~~~~~~~
./Main.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int j=i;j<s.size();j++){
      |                         ~^~~~~~~~~
./Main.cpp:6:25: warning: unused variable 'p' [-Wunused-variable]
    6 |     int a=0,c=0,f=0,g=0,p=0;
      |                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 4
AC × 16
WA × 11
TLE × 6
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 3576 KiB
00_sample_01.txt AC 1 ms 3576 KiB
00_sample_02.txt AC 1 ms 3580 KiB
00_sample_03.txt AC 1 ms 3412 KiB
01_random_00.txt AC 3 ms 3876 KiB
01_random_01.txt AC 4 ms 3836 KiB
01_random_02.txt AC 9 ms 4272 KiB
02_random2_00.txt AC 6 ms 3932 KiB
02_random2_01.txt TLE > 2000 ms 4424 KiB
02_random2_02.txt WA 9 ms 4548 KiB
02_random2_03.txt WA 8 ms 4452 KiB
02_random2_04.txt WA 7 ms 4120 KiB
02_random2_05.txt WA 5 ms 4088 KiB
02_random2_06.txt TLE > 2000 ms 3996 KiB
02_random2_07.txt WA 6 ms 3940 KiB
02_random2_08.txt TLE > 2000 ms 4140 KiB
02_random2_09.txt TLE > 2000 ms 4264 KiB
02_random2_10.txt WA 1733 ms 4340 KiB
02_random2_11.txt WA 8 ms 4196 KiB
03_random3_00.txt AC 1003 ms 4460 KiB
03_random3_01.txt AC 7 ms 4024 KiB
03_random3_02.txt TLE > 2000 ms 4172 KiB
03_random3_03.txt AC 7 ms 4196 KiB
04_handmade_00.txt AC 1 ms 3612 KiB
04_handmade_01.txt WA 1 ms 3580 KiB
04_handmade_02.txt WA 1 ms 3400 KiB
04_handmade_03.txt AC 1 ms 3400 KiB
04_handmade_04.txt AC 8 ms 4272 KiB
04_handmade_05.txt AC 175 ms 4316 KiB
04_handmade_06.txt TLE > 2000 ms 4364 KiB
04_handmade_07.txt AC 9 ms 4544 KiB
04_handmade_08.txt WA 6 ms 3960 KiB
04_handmade_09.txt WA 5 ms 3940 KiB