제출 #398837

#제출 시각아이디문제언어결과실행 시간메모리
398837fun_dayPalindromic Partitions (CEOI17_palindromic)C++14
100 / 100
3829 ms13116 KiB
#include <bits/stdc++.h> using namespace std; vector<char> reversed(vector<char>ss){ reverse(ss.begin(),ss.end()); return ss; } void clear(queue<char> &q){ std::queue<char> empty; std::swap( q, empty ); } bool equal(string one , string two){ unordered_map<string , bool>mp; mp[one] = 1; return mp[two]; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int tt; cin >> tt; while(tt--){ string ss ; cin >> ss; int n = ss.length(); int ans = 1; deque<char>one ,two; unordered_map<char , int>occ; unordered_map<char , int>occ2; for(int i = 0, r = n-1 ; i <n/2 ; i++,r--){ one.push_back(ss[i]); two.push_front(ss[r]); occ[ss[i]]++; occ2[ss[r]]++; bool is = 1; for(char z = 'a' ; z<='z' ; z++){ if(occ[z]!=occ2[z]){ is = 0; break; } } if((!is)||(two.front() != one.front())||(two.back()!=one.back()))continue; if(one == two){ one.clear(); two.clear(); ans+=2; occ.clear(); occ2.clear(); if(i+1==r)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...