Submission #19726222


Source Code Expand

Copy
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

ll Inf=10000000000000000;




int main() {
    
    int N;
    cin>>N;
    int b=0;
    int a=0;
    int c=0;
    int count=0;
    
    
    vector<string> s(N);
    
    for(int i=0;i<N;i++){
        cin>>s[i];
        if(s[i][0]=='B'){
            b++;
        }
        if(s[i][s[i].size()-1]=='A'){
            //cout<<s[i]<<endl;
            a++;
        }
        if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A'){
            c++;
        }
        for(int j=0;j<s[i].size()-1;j++){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                count++;
            }
        }
    }
    
    //cout<<count<<" : "<<a<<" : "<<b<<endl;
    
    if(a==b&&b==c){
        count+=a-1;
    }else{
        count+=min(a,b);
    }
    
    cout<<count<<endl;

    
}

Submission Info

Submission Time
Task C - AB Substrings
User e6i24v
Language C++ (GCC 9.2.1)
Score 0
Code Size 880 Byte
Status WA
Exec Time 12 ms
Memory 3728 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:22: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   36 |         for(int j=0;j<s[i].size()-1;j++){
      |                     ~^~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 46
WA × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, rand_06.txt, rand_07.txt, rand_08.txt, rand_09.txt, rand_10.txt, rand_11.txt, rand_12.txt, rand_13.txt, rand_14.txt, rand_15.txt, rand_16.txt, rand_17.txt, rand_18.txt, rand_19.txt, rand_20.txt, rand_21.txt, rand_22.txt, rand_23.txt, rand_24.txt, rand_25.txt, rand_26.txt, rand_27.txt, rand_28.txt, rand_29.txt, rand_30.txt, rand_31.txt, rand_32.txt, rand_33.txt, rand_34.txt, rand_35.txt, rand_36.txt, rand_37.txt, rand_38.txt, rand_39.txt, rand_40.txt, rand_41.txt, rand_42.txt, rand_43.txt, rand_44.txt, rand_45.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
rand_01.txt WA 10 ms 3528 KB
rand_02.txt WA 7 ms 3476 KB
rand_03.txt AC 10 ms 3500 KB
rand_04.txt AC 9 ms 3524 KB
rand_05.txt AC 4 ms 3464 KB
rand_06.txt AC 7 ms 3496 KB
rand_07.txt AC 7 ms 3604 KB
rand_08.txt AC 6 ms 3548 KB
rand_09.txt AC 5 ms 3552 KB
rand_10.txt AC 6 ms 3600 KB
rand_11.txt AC 4 ms 3484 KB
rand_12.txt AC 6 ms 3528 KB
rand_13.txt AC 7 ms 3548 KB
rand_14.txt AC 5 ms 3528 KB
rand_15.txt AC 5 ms 3424 KB
rand_16.txt AC 5 ms 3472 KB
rand_17.txt AC 3 ms 3608 KB
rand_18.txt AC 5 ms 3504 KB
rand_19.txt AC 4 ms 3600 KB
rand_20.txt AC 6 ms 3520 KB
rand_21.txt AC 7 ms 3464 KB
rand_22.txt AC 6 ms 3528 KB
rand_23.txt AC 12 ms 3416 KB
rand_24.txt AC 9 ms 3580 KB
rand_25.txt AC 12 ms 3464 KB
rand_26.txt AC 7 ms 3420 KB
rand_27.txt AC 8 ms 3524 KB
rand_28.txt AC 8 ms 3444 KB
rand_29.txt AC 4 ms 3388 KB
rand_30.txt AC 6 ms 3576 KB
rand_31.txt AC 5 ms 3684 KB
rand_32.txt AC 5 ms 3580 KB
rand_33.txt AC 6 ms 3388 KB
rand_34.txt AC 5 ms 3576 KB
rand_35.txt AC 7 ms 3576 KB
rand_36.txt AC 4 ms 3612 KB
rand_37.txt AC 4 ms 3588 KB
rand_38.txt AC 11 ms 3612 KB
rand_39.txt AC 5 ms 3576 KB
rand_40.txt AC 9 ms 3500 KB
rand_41.txt AC 6 ms 3580 KB
rand_42.txt AC 5 ms 3728 KB
rand_43.txt AC 9 ms 3552 KB
rand_44.txt AC 8 ms 3600 KB
rand_45.txt AC 5 ms 3532 KB
sample_01.txt AC 2 ms 3604 KB
sample_02.txt AC 2 ms 3604 KB
sample_03.txt AC 2 ms 3524 KB