Submission #116191

# Submission time Handle Problem Language Result Execution time Memory
116191 2019-06-11T08:27:44 Z Meloric Palindromic Partitions (CEOI17_palindromic) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>

using namespace std;

bool same(int l, int r, int len, vector<int>&wrd){
    for(int i = 0; i<=len; i++){
        if(wrd[l+i] != wrd[r+i-len])return false;
    }
    return true;
}
int dp(int l, int r, vector<int>&wrd){
    for(int i = 0; i+l < r-i ;i++){
        if(same(l, r, i, wrd))return dp(l+i+1, r-i-1, wrd)+2;
    }
    return 1;
}
void solve(){
    string in; vector<int> wrd;
    cin >> in;
    for(auto i : in)wrd.pb(i-'a');
    //for(int i : wrd)cout << i <<' ';
    cout << dp(0, wrd.size()-1, wrd)<< '\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t; cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -