#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++;
}
mp.clear();
}
cout << ans << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
58 ms |
424 KB |
Output is correct |
11 |
Correct |
67 ms |
424 KB |
Output is correct |
12 |
Correct |
24 ms |
352 KB |
Output is correct |
13 |
Correct |
11 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
58 ms |
424 KB |
Output is correct |
11 |
Correct |
67 ms |
424 KB |
Output is correct |
12 |
Correct |
24 ms |
352 KB |
Output is correct |
13 |
Correct |
11 ms |
332 KB |
Output is correct |
14 |
Execution timed out |
10087 ms |
3160 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |