# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
580440 | 2022-06-21T08:52:24 Z | temporary_juggernaut | Lottery (CEOI18_lot) | C++14 | 565 ms | 15900 KB |
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; typedef long long ll; typedef long double ld; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef juggernaut #define printl(args...) printf(args) #else #define printl(args...) 0 #endif int n,l; int a[10005]; int b[2005][2005]; map<ll,int>mp; ll c[10005]; int main(){ scanf("%d%d",&n,&l); for(int i=1;i<=n;i++)scanf("%d",&a[i]); if(n<=2000){ for(int i=1;i+l-1<=n;i++){ for(int j=1;j+l-1<=n;j++){ int cnt=0; for(int k=0;k<l;k++)if(a[i+k]!=a[j+k])cnt++; b[i][cnt]++; } for(int j=1;j<2005;j++)b[i][j]+=b[i][j-1]; } int q; scanf("%d",&q); while(q--){ int x; scanf("%d",&x); for(int i=1;i+l-1<=n;i++)printf("%d ",b[i][x]-1); puts(""); } return 0; } const ll P=1e9+7; const ll mod=1e9+9; const ll P2=1e9+9; const ll mod2=(1<<29)-1; for(int i=1;i+l-1<=n;i++){ ll pw=1; ll hsh=0; ll pw2=1; ll hsh2=0; for(int j=0;j<l;j++){ hsh+=(a[i+j]*pw)%mod; hsh%=mod; pw*=P; pw%=mod; hsh2+=(a[i+j]*pw2)%mod2; hsh2%=mod2; pw2*=P2; pw2%=mod2; } mp[hsh*P+hsh2]++; c[i]=hsh*P+hsh2; } for(int i=1;i+l-1<=n;i++)printf("%d ",mp[c[i]]-1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 852 KB | Output is correct |
3 | Correct | 2 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 5 ms | 1460 KB | Output is correct |
9 | Correct | 4 ms | 1492 KB | Output is correct |
10 | Correct | 5 ms | 2516 KB | Output is correct |
11 | Correct | 5 ms | 2516 KB | Output is correct |
12 | Correct | 5 ms | 2368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 852 KB | Output is correct |
3 | Correct | 2 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 5 ms | 1460 KB | Output is correct |
9 | Correct | 4 ms | 1492 KB | Output is correct |
10 | Correct | 5 ms | 2516 KB | Output is correct |
11 | Correct | 5 ms | 2516 KB | Output is correct |
12 | Correct | 5 ms | 2368 KB | Output is correct |
13 | Correct | 46 ms | 15900 KB | Output is correct |
14 | Correct | 528 ms | 10828 KB | Output is correct |
15 | Correct | 565 ms | 10792 KB | Output is correct |
16 | Correct | 426 ms | 14352 KB | Output is correct |
17 | Correct | 479 ms | 13360 KB | Output is correct |
18 | Correct | 530 ms | 13360 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 3 ms | 468 KB | Output is correct |
3 | Correct | 4 ms | 468 KB | Output is correct |
4 | Correct | 23 ms | 524 KB | Output is correct |
5 | Correct | 224 ms | 612 KB | Output is correct |
6 | Correct | 83 ms | 796 KB | Output is correct |
7 | Correct | 253 ms | 480 KB | Output is correct |
8 | Correct | 187 ms | 488 KB | Output is correct |
9 | Correct | 32 ms | 452 KB | Output is correct |
10 | Correct | 20 ms | 444 KB | Output is correct |
11 | Correct | 25 ms | 376 KB | Output is correct |
12 | Correct | 150 ms | 840 KB | Output is correct |
13 | Correct | 216 ms | 852 KB | Output is correct |
14 | Correct | 220 ms | 844 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 3 ms | 468 KB | Output is correct |
3 | Correct | 4 ms | 468 KB | Output is correct |
4 | Correct | 23 ms | 524 KB | Output is correct |
5 | Correct | 224 ms | 612 KB | Output is correct |
6 | Correct | 83 ms | 796 KB | Output is correct |
7 | Correct | 253 ms | 480 KB | Output is correct |
8 | Correct | 187 ms | 488 KB | Output is correct |
9 | Correct | 32 ms | 452 KB | Output is correct |
10 | Correct | 20 ms | 444 KB | Output is correct |
11 | Correct | 25 ms | 376 KB | Output is correct |
12 | Correct | 150 ms | 840 KB | Output is correct |
13 | Correct | 216 ms | 852 KB | Output is correct |
14 | Correct | 220 ms | 844 KB | Output is correct |
15 | Incorrect | 39 ms | 1028 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 852 KB | Output is correct |
3 | Correct | 2 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 724 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 5 ms | 1460 KB | Output is correct |
9 | Correct | 4 ms | 1492 KB | Output is correct |
10 | Correct | 5 ms | 2516 KB | Output is correct |
11 | Correct | 5 ms | 2516 KB | Output is correct |
12 | Correct | 5 ms | 2368 KB | Output is correct |
13 | Correct | 46 ms | 15900 KB | Output is correct |
14 | Correct | 528 ms | 10828 KB | Output is correct |
15 | Correct | 565 ms | 10792 KB | Output is correct |
16 | Correct | 426 ms | 14352 KB | Output is correct |
17 | Correct | 479 ms | 13360 KB | Output is correct |
18 | Correct | 530 ms | 13360 KB | Output is correct |
19 | Correct | 2 ms | 468 KB | Output is correct |
20 | Correct | 3 ms | 468 KB | Output is correct |
21 | Correct | 4 ms | 468 KB | Output is correct |
22 | Correct | 23 ms | 524 KB | Output is correct |
23 | Correct | 224 ms | 612 KB | Output is correct |
24 | Correct | 83 ms | 796 KB | Output is correct |
25 | Correct | 253 ms | 480 KB | Output is correct |
26 | Correct | 187 ms | 488 KB | Output is correct |
27 | Correct | 32 ms | 452 KB | Output is correct |
28 | Correct | 20 ms | 444 KB | Output is correct |
29 | Correct | 25 ms | 376 KB | Output is correct |
30 | Correct | 150 ms | 840 KB | Output is correct |
31 | Correct | 216 ms | 852 KB | Output is correct |
32 | Correct | 220 ms | 844 KB | Output is correct |
33 | Incorrect | 39 ms | 1028 KB | Output isn't correct |
34 | Halted | 0 ms | 0 KB | - |