# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
450441 | 2021-08-02T21:43:36 Z | nickmet2004 | 구간 성분 (KOI15_interval) | C++11 | 148 ms | 25488 KB |
#include<bits/stdc++.h> #define f first #define s second #define int long long using namespace std; const int N = 2005; int A = 987654323; int B = 1e9 + 7; string s , t; int pw1[27]; vector<int> a[N] , b[N]; main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> s >> t; int n = s.size() , m = t.size(); pw1[0] =1; for(int i = 1; i < 26; ++i) pw1[i] = pw1[i - 1] * A % B; for(int i = 0; i < n; ++i){ int x= 0; for(int j = i; j < n; ++j){ x += pw1[s[j] - 'a']; if(x>=B)x-=B; a[j - i + 1].emplace_back(x); } } for(int i = 0; i < m; ++i){ int x= 0; for(int j = i; j < m; ++j){ x += pw1[t[j] - 'a']; if(x>=B)x-=B; b[j - i + 1].emplace_back(x); } } for(int i = min(n , m); ~i; --i){ sort(a[i].begin() , a[i].end()); sort(b[i].begin() , b[i].end()); int k = 0; for(int j= 0; j <a[i].size(); ++j){ while(a[i][j] > b[i][k] && k < b[i].size())++k; if(a[i][j] == b[i][k]){cout << i << endl; return 0;} } }cout << 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 2636 KB | Output is correct |
2 | Correct | 9 ms | 2636 KB | Output is correct |
3 | Correct | 4 ms | 3020 KB | Output is correct |
4 | Correct | 4 ms | 3020 KB | Output is correct |
5 | Correct | 15 ms | 3112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 11108 KB | Output is correct |
2 | Correct | 64 ms | 11092 KB | Output is correct |
3 | Correct | 65 ms | 11124 KB | Output is correct |
4 | Correct | 64 ms | 11104 KB | Output is correct |
5 | Correct | 63 ms | 11084 KB | Output is correct |
6 | Incorrect | 46 ms | 11084 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 16600 KB | Output is correct |
2 | Correct | 136 ms | 24900 KB | Output is correct |
3 | Correct | 123 ms | 25240 KB | Output is correct |
4 | Correct | 34 ms | 25488 KB | Output is correct |
5 | Correct | 148 ms | 24872 KB | Output is correct |