답안 #35493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
35493 2017-11-23T01:14:23 Z imaxblue Palindromic Partitions (CEOI17_palindromic) C++14
100 / 100
403 ms 12792 KB
#include <iostream>

using namespace std;

const int seed=1337, mod=1000000007;
string s;
int t, x, p, c, y;
int fwh[1000005], bwh[1000005];
int main() {
    cin >> t;
    for (int l=0; l<t; ++l){
        cin >> s;
        x=0; y=0; p=1; c=1;
        for (int l=0; l<s.size()/2; ++l){
            x=(1LL*x*seed)%mod+s[l]-'a'+1;
            y=(y+(1LL*p*(s[s.size()-l-1]-'a'+1)))%mod;
            p=(1LL*p*seed)%mod;
            if (x==y){
                //cout << l  << ' ';
                c+=2;
                x=0; y=0; p=1;
                if ((l+1)*2==s.size()) c--;
            }
        }
        //for (int l=0; l<s.size(); ++l) cout << fwh[l] << ' ' ; cout << endl;
        //for (int l=0; l<s.size(); ++l) cout << bwh[l] << ' ' ; cout << endl;
        cout << c << endl;
    }
    return 0;
}

Compilation message

palindromic.cpp: In function 'int main()':
palindromic.cpp:14:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int l=0; l<s.size()/2; ++l){
                        ^
palindromic.cpp:22:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if ((l+1)*2==s.size()) c--;
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Correct 3 ms 9828 KB Output is correct
11 Correct 3 ms 9828 KB Output is correct
12 Correct 0 ms 9828 KB Output is correct
13 Correct 3 ms 9828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9828 KB Output is correct
2 Correct 0 ms 9828 KB Output is correct
3 Correct 0 ms 9828 KB Output is correct
4 Correct 0 ms 9828 KB Output is correct
5 Correct 0 ms 9828 KB Output is correct
6 Correct 0 ms 9828 KB Output is correct
7 Correct 0 ms 9828 KB Output is correct
8 Correct 0 ms 9828 KB Output is correct
9 Correct 0 ms 9828 KB Output is correct
10 Correct 3 ms 9828 KB Output is correct
11 Correct 3 ms 9828 KB Output is correct
12 Correct 0 ms 9828 KB Output is correct
13 Correct 3 ms 9828 KB Output is correct
14 Correct 403 ms 12792 KB Output is correct
15 Correct 223 ms 12792 KB Output is correct
16 Correct 369 ms 12792 KB Output is correct
17 Correct 196 ms 11352 KB Output is correct