제출 #468999

#제출 시각아이디문제언어결과실행 시간메모리
468999JosiaPalindromic Partitions (CEOI17_palindromic)C++14
60 / 100
10090 ms3144 KiB
#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;

        vector<int> hashes;

        string newS;

        for (int i = 0; i<n; i++) {
            newS.push_back(s[i]);
            hashes.push_back(hash<string>{}(newS));
        }




        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;
}

컴파일 시 표준 에러 (stderr) 메시지

palindromic.cpp: In function 'int main()':
palindromic.cpp:39: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]
   39 |         while (pos<=(s.size()-1)/2) {
      |                ~~~^~~~~~~~~~~~~~~~
palindromic.cpp:41:30: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'long unsigned int' [-Wsign-compare]
   41 |             for (int i = 1; i<=(s.size()-2*pos)/2; i++) {
      |                             ~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...