# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
116821 | 2019-06-14T01:48:50 Z | ntrung03 | Lozinke (COCI17_lozinke) | C | 1000 ms | 2432 KB |
#include <stdio.h> #include <string.h> #define int long long #define mod 1204755107 #define base 31 char s[20002][12]; int h[20002][12]; int p[12]; signed main() { int n; scanf("%lld\n",&n); p[0] = 1; for(int i=1;i<12;i++)p[i] = (p[i-1]*base)%mod; int res = 0; for(int i=0;i<n;i++) scanf("%s\n",s[i]); for(int i=0;i<n;i++) { for(int j=0;j<strlen(s[i]);j++) { h[i][j] = (j>0?h[i][j-1]:0); h[i][j] = ((h[i][j]*base)%mod+s[i][j]-'a'+1)%mod; } } for(int i=0;i<n;i++) { int l = strlen(s[i]); for(int j=0;j<n;j++) if(i!=j){ int sz = strlen(s[j]); for(int k = sz-1;k<l;k++){ int l = k-sz+1; int r = k; long long ph = h[i][r]-(l>0?h[i][l-1]*p[r-l+1]:0)%mod; if(ph==h[j][sz-1]){ res++; break; } } } } printf("%lld",res); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Incorrect | 16 ms | 384 KB | Output isn't correct |
6 | Incorrect | 33 ms | 504 KB | Output isn't correct |
7 | Correct | 62 ms | 512 KB | Output is correct |
8 | Correct | 54 ms | 512 KB | Output is correct |
9 | Execution timed out | 1073 ms | 1408 KB | Time limit exceeded |
10 | Execution timed out | 1056 ms | 1408 KB | Time limit exceeded |
11 | Execution timed out | 1056 ms | 1920 KB | Time limit exceeded |
12 | Execution timed out | 1065 ms | 1920 KB | Time limit exceeded |
13 | Execution timed out | 1066 ms | 2432 KB | Time limit exceeded |
14 | Execution timed out | 1075 ms | 2432 KB | Time limit exceeded |
15 | Execution timed out | 1065 ms | 2432 KB | Time limit exceeded |
16 | Execution timed out | 1066 ms | 2432 KB | Time limit exceeded |
17 | Execution timed out | 1076 ms | 2432 KB | Time limit exceeded |
18 | Execution timed out | 1066 ms | 2432 KB | Time limit exceeded |
19 | Execution timed out | 1073 ms | 2432 KB | Time limit exceeded |
20 | Execution timed out | 1073 ms | 2432 KB | Time limit exceeded |