답안 #1116554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116554 2024-11-21T19:48:15 Z PagodePaiva Palindromic Partitions (CEOI17_palindromic) C++17
0 / 100
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

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++){
      |                       ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 592 KB Output isn't correct
2 Halted 0 ms 0 KB -