답안 #94428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94428 2019-01-18T12:03:03 Z choikiwon Joyful KMP (KRIII5_JK) C++17
2 / 7
58 ms 6472 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int MN = 1000010;

string S;
ll K;
int pi[MN];

int main() {
    std::ios::sync_with_stdio(false);

    cin >> S >> K;

    int ans = 26;
    for(int i = 1, j = 0; i < S.size(); i++) {
        vector<int> chk(26, 0);
        int cnt = 0;
        while(j && S[i] != S[j]) {
            if(!chk[ S[j] - 'a' ]) {
                chk[ S[j] - 'a' ] = 1;
                cnt++;
            }
            j = pi[j - 1];
        }
        if(S[i] == S[j]) {
            pi[i] = ++j;
        }
        else {
            if(!chk[ S[0] - 'a' ]) cnt++;
            ans = 1LL * ans * (26 - cnt) % mod;
        }
    }

    cout << ans << endl;
}

Compilation message

JK.cpp: In function 'int main()':
JK.cpp:19:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1, j = 0; i < S.size(); i++) {
                           ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 376 KB Output is partially correct
2 Partially correct 2 ms 376 KB Output is partially correct
3 Partially correct 2 ms 376 KB Output is partially correct
4 Partially correct 2 ms 516 KB Output is partially correct
5 Partially correct 51 ms 6396 KB Output is partially correct
6 Partially correct 51 ms 6344 KB Output is partially correct
7 Partially correct 52 ms 6396 KB Output is partially correct
8 Partially correct 54 ms 6404 KB Output is partially correct
9 Partially correct 50 ms 6396 KB Output is partially correct
10 Partially correct 2 ms 376 KB Output is partially correct
11 Partially correct 2 ms 376 KB Output is partially correct
12 Partially correct 2 ms 376 KB Output is partially correct
13 Partially correct 2 ms 376 KB Output is partially correct
14 Partially correct 3 ms 376 KB Output is partially correct
15 Partially correct 5 ms 760 KB Output is partially correct
16 Partially correct 8 ms 1016 KB Output is partially correct
17 Partially correct 29 ms 3444 KB Output is partially correct
18 Partially correct 54 ms 6284 KB Output is partially correct
19 Partially correct 54 ms 6400 KB Output is partially correct
20 Partially correct 58 ms 6412 KB Output is partially correct
21 Partially correct 58 ms 6396 KB Output is partially correct
22 Partially correct 57 ms 6400 KB Output is partially correct
23 Partially correct 47 ms 6396 KB Output is partially correct
24 Partially correct 49 ms 6400 KB Output is partially correct
25 Partially correct 47 ms 6364 KB Output is partially correct
26 Partially correct 47 ms 6400 KB Output is partially correct
27 Partially correct 46 ms 6400 KB Output is partially correct
28 Partially correct 47 ms 6400 KB Output is partially correct
29 Partially correct 46 ms 6292 KB Output is partially correct
30 Partially correct 49 ms 6396 KB Output is partially correct
31 Partially correct 47 ms 6396 KB Output is partially correct
32 Partially correct 48 ms 6396 KB Output is partially correct
33 Partially correct 48 ms 6400 KB Output is partially correct
34 Partially correct 49 ms 6400 KB Output is partially correct
35 Partially correct 50 ms 6400 KB Output is partially correct
36 Partially correct 47 ms 6396 KB Output is partially correct
37 Partially correct 48 ms 6400 KB Output is partially correct
38 Partially correct 48 ms 6472 KB Output is partially correct
39 Partially correct 49 ms 6388 KB Output is partially correct
40 Partially correct 53 ms 6400 KB Output is partially correct
41 Partially correct 49 ms 6396 KB Output is partially correct
42 Partially correct 48 ms 6396 KB Output is partially correct
43 Partially correct 49 ms 6396 KB Output is partially correct
44 Partially correct 48 ms 6396 KB Output is partially correct
45 Partially correct 49 ms 6400 KB Output is partially correct
46 Partially correct 51 ms 6400 KB Output is partially correct
47 Partially correct 49 ms 6400 KB Output is partially correct
48 Partially correct 48 ms 6396 KB Output is partially correct
49 Partially correct 48 ms 6396 KB Output is partially correct
50 Partially correct 49 ms 6400 KB Output is partially correct