# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116471 | PagodePaiva | Palindromic Partitions (CEOI17_palindromic) | C++17 | 1 ms | 336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
void solve(){
string s;
cin >> s;
int n = s.size();
int l = 0, r = s.size()-1;
int res = 0;
for(int i = 0;i < n;i++){
string a, b;
int ra = i, lb = r-(i-l+1)+1;
if(lb <= ra){
res++;
break;
}
for(int j = l;j <= i;j++){
a.push_back(s[j]);
}
for(int j = r;j > r-(i-l+1);j--){
b.push_back(s[j]);
}
reverse(b.begin(), b.end());
//cout << a << ' ' << b << '\n';
if(a.size() != b.size()) exit(0);
bool aux = true;
for(int j = 0;j < a.size();j++){
if(a[j] != b[j]) aux = false;
}
if(aux){
l = ra+1;
r = lb-1;
res += 2;
}
}
cout << res << '\n';
}
int main(){
int t;
cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | 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... |