Submission #1116471

# Submission time Handle Problem Language Result Execution time Memory
1116471 2024-11-21T16:59:44 Z PagodePaiva Palindromic Partitions (CEOI17_palindromic) C++17
0 / 100
1 ms 336 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(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

palindromic.cpp: In function 'void solve()':
palindromic.cpp:28:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for(int j = 0;j < a.size();j++){
      |                       ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -