답안 #541585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541585 2022-03-23T19:31:48 Z UncoolAnon Lottery (CEOI18_lot) C++17
100 / 100
861 ms 8264 KB
#include <bits/stdc++.h>
using namespace std; 
void print(vector<int> a){
	for(int x:a) cout << x << " "; 
	cout<<endl ; 
}
int main(){
	ios_base::sync_with_stdio(0); 
	cin.tie(nullptr); 
	int n,l,q; 
	cin>>n>>l; 
	vector<int> a(n); 
	for(int&x:a) cin>>x; 
	cin>>q; 
	vector<vector<int>> answer(q,vector<int>(n-l+1)); 
	vector<int> m(q); 
	for(int&x:m) cin>>x;
	vector<int> dif(n-l+1); 
	for(int i=0;i+l-1<n;i++){
		if(i==0){
			for(int j=0;j+l-1<n;j++){
				int d=0; 
				for(int k=j;k<j+l;k++) d+=(a[k]!=a[i+k-j]); 
				dif[j]=d; 
			}
		}
		else{
			for(int j=n-1;j>0;j--){
				if(j+l-1<n){
					dif[j]=dif[j-1]-(a[j-1]!=a[i-1]);
					dif[j]+=(a[j+l-1]!=a[i+l-1]); 
				}
			}
			dif[0]=0;
			for(int j=0;j<l;j++)
				dif[0]+=(a[i+j]!=a[j]); 
		}
		//cout << i << " :" ; print(dif); 
		vector<int> prefix(n+1); 
		for(int&x:dif) prefix[x]++; 
		for(int i=1;i<=n;i++) prefix[i]+=prefix[i-1]; 
		for(int query=0;query<q;query++)
			answer[query][i]=prefix[m[query]]-1; 
	}
	for(auto x:answer){
		for(int y:x) cout<<y<<" ";
		cout<<'\n'; 
	}
	return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 31 ms 368 KB Output is correct
14 Correct 22 ms 444 KB Output is correct
15 Correct 20 ms 400 KB Output is correct
16 Correct 31 ms 476 KB Output is correct
17 Correct 32 ms 468 KB Output is correct
18 Correct 31 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 766 ms 500 KB Output is correct
2 Correct 755 ms 492 KB Output is correct
3 Correct 809 ms 500 KB Output is correct
4 Correct 800 ms 488 KB Output is correct
5 Correct 349 ms 440 KB Output is correct
6 Correct 713 ms 488 KB Output is correct
7 Correct 358 ms 440 KB Output is correct
8 Correct 505 ms 440 KB Output is correct
9 Correct 841 ms 488 KB Output is correct
10 Correct 861 ms 488 KB Output is correct
11 Correct 45 ms 340 KB Output is correct
12 Correct 497 ms 468 KB Output is correct
13 Correct 445 ms 448 KB Output is correct
14 Correct 452 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 766 ms 500 KB Output is correct
2 Correct 755 ms 492 KB Output is correct
3 Correct 809 ms 500 KB Output is correct
4 Correct 800 ms 488 KB Output is correct
5 Correct 349 ms 440 KB Output is correct
6 Correct 713 ms 488 KB Output is correct
7 Correct 358 ms 440 KB Output is correct
8 Correct 505 ms 440 KB Output is correct
9 Correct 841 ms 488 KB Output is correct
10 Correct 861 ms 488 KB Output is correct
11 Correct 45 ms 340 KB Output is correct
12 Correct 497 ms 468 KB Output is correct
13 Correct 445 ms 448 KB Output is correct
14 Correct 452 ms 444 KB Output is correct
15 Correct 794 ms 492 KB Output is correct
16 Correct 744 ms 488 KB Output is correct
17 Correct 835 ms 500 KB Output is correct
18 Correct 803 ms 496 KB Output is correct
19 Correct 848 ms 492 KB Output is correct
20 Correct 841 ms 588 KB Output is correct
21 Correct 821 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 31 ms 368 KB Output is correct
14 Correct 22 ms 444 KB Output is correct
15 Correct 20 ms 400 KB Output is correct
16 Correct 31 ms 476 KB Output is correct
17 Correct 32 ms 468 KB Output is correct
18 Correct 31 ms 460 KB Output is correct
19 Correct 766 ms 500 KB Output is correct
20 Correct 755 ms 492 KB Output is correct
21 Correct 809 ms 500 KB Output is correct
22 Correct 800 ms 488 KB Output is correct
23 Correct 349 ms 440 KB Output is correct
24 Correct 713 ms 488 KB Output is correct
25 Correct 358 ms 440 KB Output is correct
26 Correct 505 ms 440 KB Output is correct
27 Correct 841 ms 488 KB Output is correct
28 Correct 861 ms 488 KB Output is correct
29 Correct 45 ms 340 KB Output is correct
30 Correct 497 ms 468 KB Output is correct
31 Correct 445 ms 448 KB Output is correct
32 Correct 452 ms 444 KB Output is correct
33 Correct 794 ms 492 KB Output is correct
34 Correct 744 ms 488 KB Output is correct
35 Correct 835 ms 500 KB Output is correct
36 Correct 803 ms 496 KB Output is correct
37 Correct 848 ms 492 KB Output is correct
38 Correct 841 ms 588 KB Output is correct
39 Correct 821 ms 492 KB Output is correct
40 Correct 810 ms 1996 KB Output is correct
41 Correct 56 ms 564 KB Output is correct
42 Correct 758 ms 2032 KB Output is correct
43 Correct 737 ms 1684 KB Output is correct
44 Correct 712 ms 1832 KB Output is correct
45 Correct 813 ms 8068 KB Output is correct
46 Correct 60 ms 1096 KB Output is correct
47 Correct 845 ms 8264 KB Output is correct
48 Correct 769 ms 6340 KB Output is correct
49 Correct 780 ms 7120 KB Output is correct