이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |