Submission #111206

#TimeUsernameProblemLanguageResultExecution timeMemory
111206dndhkPalindromic Partitions (CEOI17_palindromic)C++14
60 / 100
10033 ms5912 KiB
#include <bits/stdc++.h> #define pb push_back #define all(v) ((v).begin(), (v).end()) #define sortv(v) sort(all(v)) #define sz(v) ((int)(v).size()) #define uniqv(v) (v).erase(unique(all(v)), (v).end()) #define umax(a, b) (a)=max((a), (b)) #define umin(a, b) (a)=min((a), (b)) #define FOR(i,a,b) for(int i = (a); i <= (b); i++) #define rep(i,n) FOR(i,1,n) #define rep0(i,n) FOR(i,0,(int)(n)-1) #define FI first #define SE second #define INF 2000000000 #define INFLL 1000000000000000000LL using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; int T; string str; string str1, str2; int calc(int x, int y){ if(x>y) return 0; if(x==y) return 1; int l = 1; while(!str1.empty()) str1.pop_back(); while(!str2.empty()) str2.pop_back(); while(1){ if(x+l-1 > y-l+1) return 1; str1.push_back(str[x+l-1]); str2.insert(0, 1, (char)str[y-l+1]); if(str1==str2){ return 2+calc(x+l, y-l); } l++; } } int main(){ cin>>T; while(T--){ cin>>str; cout<<calc(0, str.size()-1)<<endl; } 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...