Submission #261172

#TimeUsernameProblemLanguageResultExecution timeMemory
261172sjimedLottery (CEOI18_lot)C++14
100 / 100
872 ms8368 KiB
#include<bits/stdc++.h>  
using namespace std;  
  
#define fast ios::sync_with_stdio(false);cin.tie(NULL)  
#define fi first  
#define se second  
#define all(v) (v).begin(),(v).end()  
#define pb push_back  
#define eb emplace_back
#define em emplace
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
  
typedef long long ll;  
typedef pair<int,int> pii;  
typedef pair<ll,ll> pll;  
const ll INF = 1e18;
const int inf = 1e9;

int n, l, q;
int a[10010];
int k[111];
int g[10010];
int ans[111][10010];

int main() {
	fast;

	cin >> n >> l;

	for(int i=1; i<=n; i++) {
		cin >> a[i];
	}

	cin >> q;

	vector<int> v;
	for(int i=1; i<=q; i++) {
		cin >> k[i];
		v.eb(k[i]);
	}

	v.eb(l);
	
	sort(all(v));
	v.erase(unique(all(v)), v.end());

	for(int i=0, j=0; i<v.size(); i++) {
		for( ; j<=v[i]; j++) g[j] = i;
	}

	for(int i=1; i<=n-l; i++) {
		int cnt = 0;
		for(int j=1; j<=l; j++) {
			if(a[j] != a[j+i]) cnt++;
		}

		for(int j=1; j+i <= n-l+1; j++) {
			ans[g[cnt]][j]++;
			ans[g[cnt]][j+i]++;
			
			if(a[j] != a[j+i]) cnt--;
			if(a[j+l] != a[j+i+l]) cnt++;
		}
	}

	for(int i=1; i<=q; i++) {
		for(int j=1; j<=n-l+1; j++) {
			ans[i][j] += ans[i-1][j];
		}
	}

	for(int i=1; i<=q; i++) {
		for(int j=1; j<=n-l+1; j++) {
			cout << ans[g[k[i]]][j] << " ";	
		}

		cout << "\n";
	}
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0, j=0; i<v.size(); i++) {
                    ~^~~~~~~~~
#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...