# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26677 | 2017-07-04T16:28:41 Z | TAMREF | 구간 성분 (KOI15_interval) | C++11 | 276 ms | 2160 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=1e9+7; ll pow1500[26]={1}; char A[1505], B[1505]; int N,M; set<ll> S; void init(){ for(int i=1;i<26;i++) pow1500[i]=(pow1500[i-1]*26)%mod; fgets(A,1502,stdin); N=strlen(A); A[--N]=0; fgets(B,1502,stdin); M=strlen(B); B[--M]=0; for(int i=0;i<N;i++) A[i]&=15; for(int i=0;i<M;i++) B[i]&=15; } bool pro(int x){ S.clear(); ll H=0; for(int i=0;i<x;i++) H=(H+pow1500[A[i]-1])%mod; S.insert(H); for(int i=x;i<N;i++){ H=(((H+pow1500[A[i]-1])%mod-pow1500[A[i-x]-1])%mod+mod)%mod; S.insert(H); } H=0; for(int i=0;i<x;i++) H=(H+pow1500[B[i]-1])%mod; if(S.find(H)!=S.end()) return true; for(int i=x;i<M;i++){ H=(((H+pow1500[B[i]-1])%mod-pow1500[B[i-x]-1])%mod+mod)%mod; if(S.find(H)!=S.end()) return true; } return false; } int main(){ init(); int ans=0, x=min(N,M); for(int i=1;i<=x;i++) if(pro(i)) ans=max(ans,i); printf("%d\n",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2028 KB | Output is correct |
2 | Correct | 0 ms | 2028 KB | Output is correct |
3 | Correct | 0 ms | 2028 KB | Output is correct |
4 | Correct | 0 ms | 2028 KB | Output is correct |
5 | Correct | 0 ms | 2028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 2028 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 126 ms | 2028 KB | Output is correct |
2 | Incorrect | 133 ms | 2028 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 2028 KB | Output is correct |
2 | Incorrect | 276 ms | 2160 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |