Submission #116192

#TimeUsernameProblemLanguageResultExecution timeMemory
116192MeloricPalindromic Partitions (CEOI17_palindromic)C++14
60 / 100
10010 ms13420 KiB
#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){ if(r<l)return 0; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...