답안 #606905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
606905 2022-07-26T09:48:44 Z pakhomovee Palindromic Partitions (CEOI17_palindromic) C++17
60 / 100
10000 ms 6408 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() - 1) / 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;
    }
    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() - 1) / 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) {
      |                ~~~~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 588 KB Output is correct
11 Correct 6 ms 456 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 588 KB Output is correct
11 Correct 6 ms 456 KB Output is correct
12 Correct 3 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Execution timed out 10080 ms 6408 KB Time limit exceeded
15 Halted 0 ms 0 KB -