Submission #468934

# Submission time Handle Problem Language Result Execution time Memory
468934 2021-08-30T08:35:30 Z Autumn Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 3432 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

bool check(int s1, int s2, int l, string s){
    for(int i=0;i<l;i++){
        if(s[s1]!=s[s2])return false;
        s1++;
        s2++;
    }
    return true;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    for(int T=0;T<t;T++){
        string s;
        cin>>s;
        int n=s.size();
        int pal=1;
        int is=0;
        int jcurr=n-1;
        int jend=n;
        
        while(jcurr>=(n+1)/2){    
            
            if(check(is,jcurr,jend-jcurr, s)){
                if(jcurr==n/2)pal--;
                pal+=2;
                is+=(jend-jcurr);
                jend=jcurr;
                
            }
            jcurr--;
        }
        cout<<pal<<"\n";


    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 36 ms 332 KB Output is correct
11 Correct 14 ms 372 KB Output is correct
12 Correct 27 ms 436 KB Output is correct
13 Correct 16 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 36 ms 332 KB Output is correct
11 Correct 14 ms 372 KB Output is correct
12 Correct 27 ms 436 KB Output is correct
13 Correct 16 ms 332 KB Output is correct
14 Execution timed out 10050 ms 3432 KB Time limit exceeded
15 Halted 0 ms 0 KB -