답안 #71116

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71116 2018-08-24T07:05:20 Z 3zp 구간 성분 (KOI15_interval) C++14
30 / 100
1000 ms 47392 KB
#include<bits/stdc++.h>
using namespace std;
int A = 987654323;
int B = 1e9 + 7;
int pol[26];
set<int> sa[1509];
main(){
    pol[0] = 1;
    for(int i = 1; i < 26; i ++)
        pol[i] = (long long)pol[i - 1] * (long long)A % B;
    int n, m;
    string a, b;
    cin >> a >> b;
    n = a.size(), m = b.size();
    for(int i = 0; i < n; i++){
        long long H = 0;
        for(int j = i; j < n; j++){
            H += pol[a[j] - 'a'];
            if(H > B) H -= B;
            sa[j - i + 1].insert(H);
        }
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        long long H = 0;
        for(int j = i; j < m; j++){
            H += pol[b[j] - 'a'];
            if(H > B) H -= B;
            if(sa[j - i + 1].find(H) != sa[j - i + 1].end()){
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;


}

Compilation message

interval.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 3 ms 576 KB Output is correct
4 Correct 5 ms 848 KB Output is correct
5 Correct 4 ms 848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 4076 KB Output is correct
2 Correct 77 ms 5108 KB Output is correct
3 Correct 10 ms 5108 KB Output is correct
4 Correct 5 ms 5108 KB Output is correct
5 Correct 102 ms 5872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 839 ms 22340 KB Output is correct
2 Correct 756 ms 23020 KB Output is correct
3 Correct 773 ms 23020 KB Output is correct
4 Correct 777 ms 23020 KB Output is correct
5 Correct 889 ms 23020 KB Output is correct
6 Incorrect 756 ms 23020 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 23020 KB Output is correct
2 Execution timed out 1067 ms 47392 KB Time limit exceeded
3 Halted 0 ms 0 KB -