# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223105 | 2020-04-14T18:53:25 Z | MKopchev | Lottery (CEOI18_lot) | C++14 | 1150 ms | 8440 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=1e4+42,qmax=1e2+5; int n,l; int inp[nmax]; pair<int/*k*/,int/*id*/> queries[nmax]; int where_begins[nmax]; int pref[nmax]; int output[qmax][nmax]; int original[nmax]; int q; int main() { scanf("%i%i",&n,&l); for(int i=1;i<=n;i++)scanf("%i",&inp[i]); scanf("%i",&q); for(int i=1;i<=q;i++) { scanf("%i",&queries[i].first); queries[i].second=i; original[i]=queries[i].first; } sort(queries+1,queries+q+1); for(int i=1;i<=n;i++) where_begins[i]=lower_bound(queries+1,queries+q+1,make_pair(i,0))-queries; for(int diff=1;diff<=n;diff++) { for(int i=1;i<=n;i++)pref[i]=0; for(int s=1;s+diff<=n;s++) { int t=s+diff; if(inp[s]==inp[t])continue; //common of [0, l-1], [-inf, s-1], [t-n+l-1,+inf] int i_low=max(0,t-n+l-1),i_high=min(s-1,l-1); //all [s-i, t-i] for i_low<=i<=i_high gain 1 pref[s-i_high]++; pref[s-i_low+1]--; //cout<<s<<" "<<t<<" "<<i_low<<" "<<i_high<<endl; } for(int i=1;i<=n-l+1;i++) pref[i]=pref[i]+pref[i-1]; for(int s=1;s+diff<=n-l+1;s++) { int t=s+diff; //difference between s and t is pref[s] int current=pref[s]; //cout<<"distance between "<<s<<" and "<<t<<" is "<<current<<endl; output[where_begins[current]][s]++; output[where_begins[current]][t]++; } } for(int i=1;i<=q;i++) for(int j=1;j<=n;j++) output[i][j]+=output[i-1][j]; for(int i=1;i<=q;i++) { for(int j=1;j<=n-l+1;j++) { if(j!=1)printf(" "); printf("%i",output[where_begins[original[i]]][j]); } printf("\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 512 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 512 KB | Output is correct |
12 | Correct | 6 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 512 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 512 KB | Output is correct |
12 | Correct | 6 ms | 512 KB | Output is correct |
13 | Correct | 38 ms | 504 KB | Output is correct |
14 | Correct | 30 ms | 768 KB | Output is correct |
15 | Correct | 28 ms | 640 KB | Output is correct |
16 | Correct | 37 ms | 760 KB | Output is correct |
17 | Correct | 34 ms | 768 KB | Output is correct |
18 | Correct | 34 ms | 764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1034 ms | 576 KB | Output is correct |
2 | Correct | 1037 ms | 596 KB | Output is correct |
3 | Correct | 827 ms | 632 KB | Output is correct |
4 | Correct | 750 ms | 668 KB | Output is correct |
5 | Correct | 391 ms | 632 KB | Output is correct |
6 | Correct | 711 ms | 768 KB | Output is correct |
7 | Correct | 349 ms | 760 KB | Output is correct |
8 | Correct | 500 ms | 632 KB | Output is correct |
9 | Correct | 744 ms | 760 KB | Output is correct |
10 | Correct | 756 ms | 760 KB | Output is correct |
11 | Correct | 51 ms | 384 KB | Output is correct |
12 | Correct | 489 ms | 604 KB | Output is correct |
13 | Correct | 461 ms | 632 KB | Output is correct |
14 | Correct | 462 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1034 ms | 576 KB | Output is correct |
2 | Correct | 1037 ms | 596 KB | Output is correct |
3 | Correct | 827 ms | 632 KB | Output is correct |
4 | Correct | 750 ms | 668 KB | Output is correct |
5 | Correct | 391 ms | 632 KB | Output is correct |
6 | Correct | 711 ms | 768 KB | Output is correct |
7 | Correct | 349 ms | 760 KB | Output is correct |
8 | Correct | 500 ms | 632 KB | Output is correct |
9 | Correct | 744 ms | 760 KB | Output is correct |
10 | Correct | 756 ms | 760 KB | Output is correct |
11 | Correct | 51 ms | 384 KB | Output is correct |
12 | Correct | 489 ms | 604 KB | Output is correct |
13 | Correct | 461 ms | 632 KB | Output is correct |
14 | Correct | 462 ms | 632 KB | Output is correct |
15 | Correct | 810 ms | 584 KB | Output is correct |
16 | Correct | 687 ms | 780 KB | Output is correct |
17 | Correct | 786 ms | 704 KB | Output is correct |
18 | Correct | 769 ms | 904 KB | Output is correct |
19 | Correct | 768 ms | 760 KB | Output is correct |
20 | Correct | 766 ms | 760 KB | Output is correct |
21 | Correct | 787 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 512 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 512 KB | Output is correct |
9 | Correct | 5 ms | 512 KB | Output is correct |
10 | Correct | 6 ms | 512 KB | Output is correct |
11 | Correct | 6 ms | 512 KB | Output is correct |
12 | Correct | 6 ms | 512 KB | Output is correct |
13 | Correct | 38 ms | 504 KB | Output is correct |
14 | Correct | 30 ms | 768 KB | Output is correct |
15 | Correct | 28 ms | 640 KB | Output is correct |
16 | Correct | 37 ms | 760 KB | Output is correct |
17 | Correct | 34 ms | 768 KB | Output is correct |
18 | Correct | 34 ms | 764 KB | Output is correct |
19 | Correct | 1034 ms | 576 KB | Output is correct |
20 | Correct | 1037 ms | 596 KB | Output is correct |
21 | Correct | 827 ms | 632 KB | Output is correct |
22 | Correct | 750 ms | 668 KB | Output is correct |
23 | Correct | 391 ms | 632 KB | Output is correct |
24 | Correct | 711 ms | 768 KB | Output is correct |
25 | Correct | 349 ms | 760 KB | Output is correct |
26 | Correct | 500 ms | 632 KB | Output is correct |
27 | Correct | 744 ms | 760 KB | Output is correct |
28 | Correct | 756 ms | 760 KB | Output is correct |
29 | Correct | 51 ms | 384 KB | Output is correct |
30 | Correct | 489 ms | 604 KB | Output is correct |
31 | Correct | 461 ms | 632 KB | Output is correct |
32 | Correct | 462 ms | 632 KB | Output is correct |
33 | Correct | 810 ms | 584 KB | Output is correct |
34 | Correct | 687 ms | 780 KB | Output is correct |
35 | Correct | 786 ms | 704 KB | Output is correct |
36 | Correct | 769 ms | 904 KB | Output is correct |
37 | Correct | 768 ms | 760 KB | Output is correct |
38 | Correct | 766 ms | 760 KB | Output is correct |
39 | Correct | 787 ms | 640 KB | Output is correct |
40 | Correct | 1068 ms | 2144 KB | Output is correct |
41 | Correct | 214 ms | 1400 KB | Output is correct |
42 | Correct | 827 ms | 2192 KB | Output is correct |
43 | Correct | 746 ms | 1784 KB | Output is correct |
44 | Correct | 776 ms | 1952 KB | Output is correct |
45 | Correct | 1150 ms | 8312 KB | Output is correct |
46 | Correct | 225 ms | 4856 KB | Output is correct |
47 | Correct | 894 ms | 8440 KB | Output is correct |
48 | Correct | 847 ms | 6740 KB | Output is correct |
49 | Correct | 841 ms | 7288 KB | Output is correct |