Submission #918557

# Submission time Handle Problem Language Result Execution time Memory
918557 2024-01-30T06:39:26 Z PM1 Lottery (CEOI18_lot) C++17
100 / 100
531 ms 8336 KB
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
const int mxn=1e4+4,mxq=102;
int n,q,ans[mxq][mxn],l;
pair<int,int>b[mxq];
int a[mxn],loc[mxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>l;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>b[i].fr;
		b[i].sc=i;
	}
	sort(b+1,b+q+1);
	int p=1;
	for(int i=0;i<=l;i++){
		while(p<=q && b[p].fr<i)p++;
		loc[i]=p;
	}
	for(int k=1;k<=n-l;k++){
		int cnt=0;
		for(int i=0;i<l;i++)
			if(a[1+i]==a[1+k+i])cnt++;
		ans[b[loc[l-cnt]].sc][1]++;
		ans[b[loc[l-cnt]].sc][k+1]++;
		//cout<<l-cnt<<" ";
		for(int i=2;i+k<=n-l+1;i++){
			if(a[i+l-1]==a[i+k+l-1])cnt++;
			if(a[i-1]==a[i+k-1])cnt--;
			ans[b[loc[l-cnt]].sc][i]++;
			ans[b[loc[l-cnt]].sc][i+k]++;
			//cout<<l-cnt<<" ";
		}
		//cout<<endl;
	}
	for(int i=2;i<=q;i++)
		for(int j=1;j<=n-l+1;j++)
			ans[b[i].sc][j]+=ans[b[i-1].sc][j];

	for(int i=1;i<=q;i++){
		for(int j=1;j<=n-l+1;j++)
			cout<<ans[i][j]<<" ";
		cout<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 7 ms 2396 KB Output is correct
14 Correct 4 ms 2396 KB Output is correct
15 Correct 5 ms 2548 KB Output is correct
16 Correct 6 ms 2652 KB Output is correct
17 Correct 6 ms 2392 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 309 ms 596 KB Output is correct
2 Correct 460 ms 596 KB Output is correct
3 Correct 141 ms 604 KB Output is correct
4 Correct 112 ms 660 KB Output is correct
5 Correct 43 ms 640 KB Output is correct
6 Correct 102 ms 644 KB Output is correct
7 Correct 38 ms 604 KB Output is correct
8 Correct 62 ms 856 KB Output is correct
9 Correct 109 ms 604 KB Output is correct
10 Correct 115 ms 652 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 67 ms 604 KB Output is correct
13 Correct 55 ms 632 KB Output is correct
14 Correct 61 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 309 ms 596 KB Output is correct
2 Correct 460 ms 596 KB Output is correct
3 Correct 141 ms 604 KB Output is correct
4 Correct 112 ms 660 KB Output is correct
5 Correct 43 ms 640 KB Output is correct
6 Correct 102 ms 644 KB Output is correct
7 Correct 38 ms 604 KB Output is correct
8 Correct 62 ms 856 KB Output is correct
9 Correct 109 ms 604 KB Output is correct
10 Correct 115 ms 652 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 67 ms 604 KB Output is correct
13 Correct 55 ms 632 KB Output is correct
14 Correct 61 ms 616 KB Output is correct
15 Correct 165 ms 604 KB Output is correct
16 Correct 95 ms 600 KB Output is correct
17 Correct 133 ms 656 KB Output is correct
18 Correct 123 ms 652 KB Output is correct
19 Correct 107 ms 676 KB Output is correct
20 Correct 113 ms 848 KB Output is correct
21 Correct 108 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 7 ms 2396 KB Output is correct
14 Correct 4 ms 2396 KB Output is correct
15 Correct 5 ms 2548 KB Output is correct
16 Correct 6 ms 2652 KB Output is correct
17 Correct 6 ms 2392 KB Output is correct
18 Correct 7 ms 2648 KB Output is correct
19 Correct 309 ms 596 KB Output is correct
20 Correct 460 ms 596 KB Output is correct
21 Correct 141 ms 604 KB Output is correct
22 Correct 112 ms 660 KB Output is correct
23 Correct 43 ms 640 KB Output is correct
24 Correct 102 ms 644 KB Output is correct
25 Correct 38 ms 604 KB Output is correct
26 Correct 62 ms 856 KB Output is correct
27 Correct 109 ms 604 KB Output is correct
28 Correct 115 ms 652 KB Output is correct
29 Correct 11 ms 348 KB Output is correct
30 Correct 67 ms 604 KB Output is correct
31 Correct 55 ms 632 KB Output is correct
32 Correct 61 ms 616 KB Output is correct
33 Correct 165 ms 604 KB Output is correct
34 Correct 95 ms 600 KB Output is correct
35 Correct 133 ms 656 KB Output is correct
36 Correct 123 ms 652 KB Output is correct
37 Correct 107 ms 676 KB Output is correct
38 Correct 113 ms 848 KB Output is correct
39 Correct 108 ms 660 KB Output is correct
40 Correct 488 ms 3368 KB Output is correct
41 Correct 9 ms 2648 KB Output is correct
42 Correct 132 ms 3412 KB Output is correct
43 Correct 133 ms 3156 KB Output is correct
44 Correct 162 ms 3408 KB Output is correct
45 Correct 531 ms 8100 KB Output is correct
46 Correct 16 ms 3164 KB Output is correct
47 Correct 165 ms 8336 KB Output is correct
48 Correct 162 ms 6576 KB Output is correct
49 Correct 178 ms 7128 KB Output is correct