Submission #217848

# Submission time Handle Problem Language Result Execution time Memory
217848 2020-03-31T04:05:41 Z aloo123 Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
10000 ms 6548 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 998244353;
const ll INF = 1e16;
const ll LOG = 25;
 
long long binpow(long long a, long long b) {
     a %= MOD;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD ;
        a = (a * a)%MOD ;
        b >>= 1;
    }
    res%=MOD;
    return res;
}

void solve(){
    string s;
    cin>>s;
    ll n = (ll)s.size();
    //cout<<n<<endl;
    ll l= 0,r= n -1;
    string a;
    string b;
    ll ans = 0;
    ll x=-1,y=n;
    while(l < r){
        a+=s[l];
        b+=s[r];
        string c =b;reverse(all(c));
        if(c == a){
            ans += 2;
            a="";
            b="";
            x = l,y =r;
       //     cout<<l<<" "<<r<<endl;
        
        }
        l++,r--;
    }
   // for(int i = x+1;i<y;i++)cout<<s[i];cout<<endl;
   // cout<<l<<" "<<r<<endl;
    if((x+1)<=(y-1))
    ans++;
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t;cin>>t;
    while(t--){
        solve();
    }



    return 0;     
    
        
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 40 ms 512 KB Output is correct
11 Correct 38 ms 384 KB Output is correct
12 Correct 11 ms 512 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 40 ms 512 KB Output is correct
11 Correct 38 ms 384 KB Output is correct
12 Correct 11 ms 512 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Execution timed out 10038 ms 6548 KB Time limit exceeded
15 Halted 0 ms 0 KB -