#include <bits/stdc++.h>
using namespace std;
string reversed(string ss){
reverse(ss.begin(),ss.end());
return ss;
}
void clear(queue<char> &q){
std::queue<char> empty;
std::swap( q, empty );
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while(tt--){
string ss ;
cin >> ss;
int n = ss.length();
int ans = 0;
string one , two;
unordered_map<string, bool > mp;
for(int i = 0, r = n-1 ; i <n ; i++,r--){
one = move(one) + ss[i];
mp[one] = 1;
two.insert(two.begin(),ss[r]);
if(mp[two]){ // too slow comparaison
one.clear();two.clear();
ans++;
}
}
cout << ans << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |