#include <iostream>
#include <vector>
using namespace std;
bool equalStr(string& s, int p1, int p2, int ctr)
{
return s.substr(p1, ctr+1) == s.substr(p2, ctr+1);
}
int main()
{
int t; cin>>t;
while(t--)
{
string s; cin>>s;
int ptr1 = 0, ptr2= s.length() -1;
long long res = 0;
int ctr = 0;
while(ptr1 <= ptr2)
{
if(s[ptr1] == s[ptr2])
{
if(equalStr(s, ptr1, ptr2, ctr))
{
res++;
if(ptr1 != ptr2)
res++;
ptr1 += ctr+1;
ptr2--;
ctr =0;
}
else
{
ptr2--;
ctr++;
}
}
else
{
ptr2--;
ctr++;
}
}
cout<<res<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
440 KB |
Output is correct |
11 |
Correct |
5 ms |
436 KB |
Output is correct |
12 |
Correct |
5 ms |
308 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
440 KB |
Output is correct |
11 |
Correct |
5 ms |
436 KB |
Output is correct |
12 |
Correct |
5 ms |
308 KB |
Output is correct |
13 |
Correct |
3 ms |
340 KB |
Output is correct |
14 |
Execution timed out |
10024 ms |
6396 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |