Submission #987649

#TimeUsernameProblemLanguageResultExecution timeMemory
987649ErJPalindromic Partitions (CEOI17_palindromic)C++17
60 / 100
10065 ms5376 KiB
#include<bits/stdc++.h> #define ll long long #define vi vector<ll> #define vvi vector<vi> #define pp pair<ll, ll> #define inf 1000000000000000 using namespace std; string s; bool test(string x, int i, int j){ // all in bool is = true; for(int k = i; k <= j; k++){ if(x[k - i] != s[k]){ is = false; } } return is; } int main(){ int t; cin >> t; while(t--){ cin >> s; int n = s.size(); int ans = 0; int mid = n/2; string akt = ""; for(int i = 0; i < mid; i++){ akt += s[i]; if(test(akt, n - 1 - i, n - 1 - (i - akt.size() + 1))){ ans += 2; akt = ""; } } if(n %2 == 1) akt += "a"; if(akt != ""){ ans++; } cout << ans << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...