#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool isPalindrome(vector<char> &lbuf, vector<char> &rbuf, int len) {
int i = 0;
int j = len - 1;
while (j >= 0) {
if (lbuf[i] != rbuf[j]) return false;
j--;
i++;
}
return true;
}
int main() {
int t;
cin >> t;
for (int z = 0; z < t; z++) {
string input;
cin >> input;
int l = 0, r = input.size() - 1;
vector<char> lbuf;
vector<char> rbuf;
int bufSize = 0;
int ans = 1;
while (l < r) {
lbuf.push_back(input[l]);
rbuf.push_back(input[r]);
bufSize++;
l++;
r--;
if (isPalindrome(lbuf, rbuf, bufSize)) {
ans += 2;
lbuf.clear();
rbuf.clear();
bufSize = 0;
}
}
cout << ans << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |