This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3")
#include <iostream>
using namespace std;
int n;
string s;
bool check_equal(int a, int b, int l) {
for (int i = 0; i < l; i++) {
if (s[a + i] != s[b + i]) {
return false;
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while(T--) {
cin >> s;
n = s.size();
int res = 0;
int l = 0, r = n - 1;
while(l <= r) {
int len = 1;
while (!check_equal(l, r - len + 1, len)) {
len++;
}
if (len == r - l + 1) {
res++;
break;
}
res += 2;
l += len;
r -= len;
}
cout << res << "\n";
}
return 0;
}
# | 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... |