# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1116554 | 2024-11-21T19:48:15 Z | PagodePaiva | Palindromic Partitions (CEOI17_palindromic) | C++17 | 1 ms | 592 KB |
#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(2); 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(){ ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--){ solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 592 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |