Submission #606902

# Submission time Handle Problem Language Result Execution time Memory
606902 2022-07-26T09:47:01 Z pakhomovee Palindromic Partitions (CEOI17_palindromic) C++17
0 / 100
1 ms 212 KB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void solve() {
    string s;
    cin >> s;
    int i = 0;
    int ans = 0;
    while (i < s.size() / 2) {
        int len = 1;
        bool ok = false;
        for (; i + len <= s.size() / 2; ++len) {
            if (s.substr(i, len) == s.substr(s.size() - i - len, len)) {
                ok = true;
                break;
            }
        }
        i += len;
        ans += 1 + ok;
    }
    if (i == s.size() / 2) ++ans;
    cout << ans << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
}

Compilation message

palindromic.cpp: In function 'void solve()':
palindromic.cpp:12:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     while (i < s.size() / 2) {
      |            ~~^~~~~~~~~~~~~~
palindromic.cpp:15:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (; i + len <= s.size() / 2; ++len) {
      |                ~~~~~~~~^~~~~~~~~~~~~~~
palindromic.cpp:24:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     if (i == s.size() / 2) ++ans;
      |         ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -