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