Submission #757813

#TimeUsernameProblemLanguageResultExecution timeMemory
757813taherPalindromic Partitions (CEOI17_palindromic)C++17
100 / 100
693 ms13144 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int tt; cin >> tt; while(tt--){ string ss;cin >> ss; int len = ss.length(); deque<char> a, b; int ans = 1; unordered_map<char,int>occ; unordered_map<char,int>occ2; for(int i = 0,r = len-1 ; i < len/2 ; i++,r--){ a.push_back(ss[i]); b.push_front(ss[r]); occ[ss[i]]++; occ2[ss[r]]++; if(a.back()!=b.back()||a.front()!=b.front())continue; bool it = 1; for(char j = 'a' ; j<='z' && it; j++){ if(occ[j]!=occ2[j]){ it = 0; continue; } } if(!it)continue; if(a==b){ ans+=2; a.clear() ; b.clear(); if((i+1)*2-len==0)ans--; } } cout << ans << '\n'; } 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...