Submission #311065

#TimeUsernameProblemLanguageResultExecution timeMemory
311065tigichaLottery (CEOI18_lot)C++14
100 / 100
981 ms12536 KiB
#include<bits/stdc++.h>
using namespace std;
int n, l, q, k, t, a[100005], b[100005], mas[100005], aray[100005][105], ans[100005][105];
pair<int, int>ar[100005];
int main(){
	cin>>n>>l;
	for(int i=1; i<=n; i++)
	cin>>a[i];
	cin>>q;
	for(int i=1; i<=q; i++){
		cin>>ar[i].first;
		ar[i].second=i;
	}
	sort(ar+1, ar+q+1);
	k=1;
	for(int i=0; i<=n; i++){
		while(ar[k].first<i && k<=q) 
		k++;
		mas[i]=k;
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n-i; j++){
			b[j]=0;
			if(a[j]!=a[i+j])
			b[j]=1;
		}
		for(int j=1; j<=n-i; j++){
			b[j]+=b[j-1];
			if(j>=l){
				t=b[j]-b[j-l];
				aray[j-l+1][mas[t]]++;
				aray[j+i-l+1][mas[t]]++;
			}
		}
	}
	for(int i=1; i<=q; i++)
	for(int j=1; j<=n-l+1; j++)
	ans[j][ar[i].second]=aray[j][i]+ans[j][ar[i-1].second];
	for(int i=1; i<=q; i++){
	    for(int j=1; j<=n-l+1; j++)
		cout<<ans[j][i]<<" ";
		cout<<endl;
	}
	return 0;
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:40:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |      for(int j=1; j<=n-l+1; j++)
      |      ^~~
lot.cpp:42:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |   cout<<endl;
      |   ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...