# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
71127 | 2018-08-24T07:10:19 Z | 3zp | 구간 성분 (KOI15_interval) | C++14 | 1000 ms | 47484 KB |
#include<bits/stdc++.h> using namespace std; int A = 987654323; int B = 1e9 + 9; int C = 985201597; int D = 660353359; int pol1[26]; int pol2[26]; set<pair<int,int> > sa[1509]; main(){ pol1[0] = 1; for(int i = 1; i < 26; i ++) pol1[i] = (long long)pol1[i - 1] * (long long)A % B; pol2[0] = 1; for(int i = 1; i < 26; i ++) pol2[i] = (long long)pol2[i - 1] * (long long)C % D; int n, m; string a, b; cin >> a >> b; n = a.size(), m = b.size(); for(int i = 0; i < n; i++){ int H1 = 0, H2 = 0; for(int j = i; j < n; j++){ H1 += pol1[a[j] - 'a']; H2 += pol2[a[j] - 'a']; if(H1 >= B) H1 -= B; if(H2 >= D) H2 -= D; sa[j - i + 1].insert({H1,H2}); } } int ans = 0; for(int i = 0; i < n; i++){ int H1 = 0, H2 = 0; for(int j = i; j < n; j++){ H1 += pol1[b[j] - 'a']; H2 += pol2[b[j] - 'a']; if(H1 >= B) H1 -= B; if(H2 >= D) H2 -= D; if(sa[j - i + 1].find({H1,H2}) != sa[j - i + 1].end()){ ans = max(ans, j - i + 1); } } } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 536 KB | Output is correct |
3 | Correct | 2 ms | 536 KB | Output is correct |
4 | Correct | 5 ms | 852 KB | Output is correct |
5 | Correct | 5 ms | 852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 4184 KB | Output is correct |
2 | Incorrect | 93 ms | 5024 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 764 ms | 22396 KB | Output is correct |
2 | Correct | 803 ms | 23004 KB | Output is correct |
3 | Correct | 889 ms | 23004 KB | Output is correct |
4 | Correct | 761 ms | 23004 KB | Output is correct |
5 | Correct | 763 ms | 23092 KB | Output is correct |
6 | Correct | 767 ms | 23092 KB | Output is correct |
7 | Correct | 788 ms | 23092 KB | Output is correct |
8 | Correct | 813 ms | 23204 KB | Output is correct |
9 | Correct | 746 ms | 23264 KB | Output is correct |
10 | Correct | 790 ms | 23264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 303 ms | 23264 KB | Output is correct |
2 | Execution timed out | 1077 ms | 47484 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |