Submission #260734

# Submission time Handle Problem Language Result Execution time Memory
260734 2020-08-10T19:54:58 Z bigg Lottery (CEOI18_lot) C++14
100 / 100
576 ms 8444 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10010;
#define mk(x, y) make_pair(x, y)
int v[MAXN], revid[MAXN], revk[MAXN];
std::vector<pair<int, int > > queries;
int marc[110][MAXN];
int n, l, q;
int main(){
	scanf("%d %d", &n, &l);
	for(int i = 1; i <= n; i++){
		scanf("%d",&v[i]);
	}
	

	scanf("%d", &q);
	for(int i = 1; i <= q; i++){
		int k;
		scanf("%d", &k);
		queries.push_back(mk(k, i-1));
	}
	sort(queries.begin(), queries.end());
	for(int i = 0; i < q; i++) revid[queries[i].second] = i;
	//int it1 = 0;
	for(int it2 = 0, it1 = 0; it2 <= l; it2 ++){
		while(it2 > queries[it1].first && it1 < queries.size()) it1++;
		revk[it2] = it1;
	}
	for(int it2 = 1; it2 <= n - l; it2++){
		int dif = 0;
		for(int it1 = 1; it1 <= l; it1++) dif += (v[it1] != v[it2 + it1]);
		marc[revk[dif]][1]++;
		marc[revk[dif]][1+ it2]++;
		for(int it1 = 2; it1 <= n-it2 - l + 1; it1++ ){
			dif -= (v[it1 -1] != v[it2 + it1 -1]);
			dif += (v[it1 -1 + l] != v[it2 + it1 -1 + l]);
			marc[revk[dif]][it1]++;
			marc[revk[dif]][it1 + it2]++;
		}
	}
	for(int i = 1; i < q; i++)
		for(int j = 1; j <= n; j++)
			marc[i][j] += marc[i-1][j];
	for(int i = 0; i < q; i++){
		for(int j = 1; j  <= n - l + 1; j++) printf("%d ",marc[revid[i]][j] );
		printf("\n");
	}
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:26:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(it2 > queries[it1].first && it1 < queries.size()) it1++;
                                     ~~~~^~~~~~~~~~~~~~~~
lot.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[i]);
   ~~~~~^~~~~~~~~~~~
lot.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
lot.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 1 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 1 ms 496 KB Output is correct
13 Correct 19 ms 456 KB Output is correct
14 Correct 12 ms 684 KB Output is correct
15 Correct 11 ms 512 KB Output is correct
16 Correct 19 ms 640 KB Output is correct
17 Correct 17 ms 640 KB Output is correct
18 Correct 18 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 476 ms 632 KB Output is correct
2 Correct 476 ms 632 KB Output is correct
3 Correct 476 ms 640 KB Output is correct
4 Correct 445 ms 632 KB Output is correct
5 Correct 133 ms 632 KB Output is correct
6 Correct 403 ms 640 KB Output is correct
7 Correct 140 ms 512 KB Output is correct
8 Correct 237 ms 512 KB Output is correct
9 Correct 454 ms 632 KB Output is correct
10 Correct 460 ms 632 KB Output is correct
11 Correct 23 ms 384 KB Output is correct
12 Correct 246 ms 556 KB Output is correct
13 Correct 179 ms 512 KB Output is correct
14 Correct 176 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 476 ms 632 KB Output is correct
2 Correct 476 ms 632 KB Output is correct
3 Correct 476 ms 640 KB Output is correct
4 Correct 445 ms 632 KB Output is correct
5 Correct 133 ms 632 KB Output is correct
6 Correct 403 ms 640 KB Output is correct
7 Correct 140 ms 512 KB Output is correct
8 Correct 237 ms 512 KB Output is correct
9 Correct 454 ms 632 KB Output is correct
10 Correct 460 ms 632 KB Output is correct
11 Correct 23 ms 384 KB Output is correct
12 Correct 246 ms 556 KB Output is correct
13 Correct 179 ms 512 KB Output is correct
14 Correct 176 ms 512 KB Output is correct
15 Correct 450 ms 632 KB Output is correct
16 Correct 396 ms 632 KB Output is correct
17 Correct 476 ms 632 KB Output is correct
18 Correct 470 ms 632 KB Output is correct
19 Correct 466 ms 632 KB Output is correct
20 Correct 473 ms 640 KB Output is correct
21 Correct 471 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 1 ms 496 KB Output is correct
13 Correct 19 ms 456 KB Output is correct
14 Correct 12 ms 684 KB Output is correct
15 Correct 11 ms 512 KB Output is correct
16 Correct 19 ms 640 KB Output is correct
17 Correct 17 ms 640 KB Output is correct
18 Correct 18 ms 640 KB Output is correct
19 Correct 476 ms 632 KB Output is correct
20 Correct 476 ms 632 KB Output is correct
21 Correct 476 ms 640 KB Output is correct
22 Correct 445 ms 632 KB Output is correct
23 Correct 133 ms 632 KB Output is correct
24 Correct 403 ms 640 KB Output is correct
25 Correct 140 ms 512 KB Output is correct
26 Correct 237 ms 512 KB Output is correct
27 Correct 454 ms 632 KB Output is correct
28 Correct 460 ms 632 KB Output is correct
29 Correct 23 ms 384 KB Output is correct
30 Correct 246 ms 556 KB Output is correct
31 Correct 179 ms 512 KB Output is correct
32 Correct 176 ms 512 KB Output is correct
33 Correct 450 ms 632 KB Output is correct
34 Correct 396 ms 632 KB Output is correct
35 Correct 476 ms 632 KB Output is correct
36 Correct 470 ms 632 KB Output is correct
37 Correct 466 ms 632 KB Output is correct
38 Correct 473 ms 640 KB Output is correct
39 Correct 471 ms 632 KB Output is correct
40 Correct 490 ms 1944 KB Output is correct
41 Correct 18 ms 1280 KB Output is correct
42 Correct 479 ms 2040 KB Output is correct
43 Correct 458 ms 1912 KB Output is correct
44 Correct 452 ms 1784 KB Output is correct
45 Correct 576 ms 8312 KB Output is correct
46 Correct 26 ms 4728 KB Output is correct
47 Correct 563 ms 8444 KB Output is correct
48 Correct 527 ms 6624 KB Output is correct
49 Correct 552 ms 7236 KB Output is correct