Submission #468969

# Submission time Handle Problem Language Result Execution time Memory
468969 2021-08-30T09:56:53 Z Josia Palindromic Partitions (CEOI17_palindromic) C++14
60 / 100
10000 ms 3064 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")


#include <bits/stdc++.h>

#define int int64_t

using namespace std;




signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n; cin >> n;


    while (n--) {
        string s; cin >> s;
        int pos = 0;
        int res = 0;
        while (pos<=(s.size()-1)/2) {
            bool worksOuter = 0;
            for (int i = 1; i<=(s.size()-2*pos)/2; i++) {
                bool works = 1;
                for (int j = 0; j<i; j++) {
                    if (s[j+pos] != s[s.size()-pos-i+j]) {
                        works = 0;
                        break;
                    }
                }

                if (works) {
                    // cout << pos << " " << i << "\n";
                    worksOuter = 1;
                    pos += i;
                    res+=2;
                    break;
                }
            }
            if (!worksOuter) {
                res++;
                break;
            }
        }

        cout << res << "\n";
    }


    return 0;
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:26:19: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         while (pos<=(s.size()-1)/2) {
      |                ~~~^~~~~~~~~~~~~~~~
palindromic.cpp:28:30: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'long unsigned int' [-Wsign-compare]
   28 |             for (int i = 1; i<=(s.size()-2*pos)/2; i++) {
      |                             ~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 11 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 11 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Execution timed out 10086 ms 3064 KB Time limit exceeded
15 Halted 0 ms 0 KB -