Submission #94094

# Submission time Handle Problem Language Result Execution time Memory
94094 2019-01-16T02:12:21 Z jasony123123 Lottery (CEOI18_lot) C++11
100 / 100
1771 ms 8256 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <array>
#include <unordered_map>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;

#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFOR(i,start,end) for(int i = start; i>end; i--)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define mt make_tuple
#define mp make_pair
#define v vector
#define sf scanf
#define pf printf
#define dvar(x) cout << #x << " := " << x << "\n"
#define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n"

typedef long long ll;
typedef long double ld;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
//template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }

void io() {
#ifdef LOCAL_PROJECT 
	freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
#else 
	/* online submission */

#endif 
	ios_base::sync_with_stdio(false); cin.tie(NULL);
}

/*************************CEOI 2018 Day 1 P3 - LOT*************************/

int N, Q, L, A[10000];
v<int> quorg, qumod;
int ans[10000][101];


void add(int i, int k) {
	int qi = lower_bound(all(qumod), k) - qumod.begin();
	ans[i][qi]++;
//	cout << "add " << i << " k=" << k << "\n";
}

int main() {
	io();
	cin >> N >> L;
	FOR(i, 0, N) cin >> A[i];
	cin >> Q;
	FOR(i, 0, Q) {
		int k; cin >> k;
		quorg.push_back(k), qumod.push_back(k);
	}
	sort(all(qumod));
	qumod.push_back(INT_MAX);

	for (int t = 0, b = 1; b <= N - L; b++) {
		for (int i = t, j = b, c = 0; i <= N - L && j <= N - L; i++, j++) {
			if (i == 0)
				FORE(l, 0, L - 1)
					c += (A[i + l] != A[j + l]);
			else
				c -= (A[i - 1] != A[j - 1]), c += (A[i + L - 1] != A[j + L - 1]);
			
		//	cout << i << " " << j << " c=" << c << "\n";
			add(i, c), add(j, c);
		}
	}

	FORE(i, 0, N-L)
		FOR(j, 1, qumod.size())
			ans[i][j] += ans[i][j - 1];

	for (auto k : quorg) {
		int qi = lower_bound(all(qumod), k) - qumod.begin();
		FORE(i, 0, N-L) cout << ans[i][qi] << " ";
		cout << "\n";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 35 ms 1144 KB Output is correct
14 Correct 22 ms 952 KB Output is correct
15 Correct 19 ms 888 KB Output is correct
16 Correct 34 ms 1188 KB Output is correct
17 Correct 30 ms 1144 KB Output is correct
18 Correct 30 ms 1020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 941 ms 4384 KB Output is correct
2 Correct 874 ms 4384 KB Output is correct
3 Correct 928 ms 4472 KB Output is correct
4 Correct 889 ms 4524 KB Output is correct
5 Correct 252 ms 2424 KB Output is correct
6 Correct 818 ms 4220 KB Output is correct
7 Correct 217 ms 2552 KB Output is correct
8 Correct 431 ms 3420 KB Output is correct
9 Correct 850 ms 4372 KB Output is correct
10 Correct 887 ms 4424 KB Output is correct
11 Correct 29 ms 1204 KB Output is correct
12 Correct 459 ms 3264 KB Output is correct
13 Correct 345 ms 2936 KB Output is correct
14 Correct 338 ms 2852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 941 ms 4384 KB Output is correct
2 Correct 874 ms 4384 KB Output is correct
3 Correct 928 ms 4472 KB Output is correct
4 Correct 889 ms 4524 KB Output is correct
5 Correct 252 ms 2424 KB Output is correct
6 Correct 818 ms 4220 KB Output is correct
7 Correct 217 ms 2552 KB Output is correct
8 Correct 431 ms 3420 KB Output is correct
9 Correct 850 ms 4372 KB Output is correct
10 Correct 887 ms 4424 KB Output is correct
11 Correct 29 ms 1204 KB Output is correct
12 Correct 459 ms 3264 KB Output is correct
13 Correct 345 ms 2936 KB Output is correct
14 Correct 338 ms 2852 KB Output is correct
15 Correct 827 ms 4276 KB Output is correct
16 Correct 732 ms 4080 KB Output is correct
17 Correct 885 ms 4472 KB Output is correct
18 Correct 855 ms 4436 KB Output is correct
19 Correct 859 ms 4472 KB Output is correct
20 Correct 860 ms 4472 KB Output is correct
21 Correct 904 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 476 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 35 ms 1144 KB Output is correct
14 Correct 22 ms 952 KB Output is correct
15 Correct 19 ms 888 KB Output is correct
16 Correct 34 ms 1188 KB Output is correct
17 Correct 30 ms 1144 KB Output is correct
18 Correct 30 ms 1020 KB Output is correct
19 Correct 941 ms 4384 KB Output is correct
20 Correct 874 ms 4384 KB Output is correct
21 Correct 928 ms 4472 KB Output is correct
22 Correct 889 ms 4524 KB Output is correct
23 Correct 252 ms 2424 KB Output is correct
24 Correct 818 ms 4220 KB Output is correct
25 Correct 217 ms 2552 KB Output is correct
26 Correct 431 ms 3420 KB Output is correct
27 Correct 850 ms 4372 KB Output is correct
28 Correct 887 ms 4424 KB Output is correct
29 Correct 29 ms 1204 KB Output is correct
30 Correct 459 ms 3264 KB Output is correct
31 Correct 345 ms 2936 KB Output is correct
32 Correct 338 ms 2852 KB Output is correct
33 Correct 827 ms 4276 KB Output is correct
34 Correct 732 ms 4080 KB Output is correct
35 Correct 885 ms 4472 KB Output is correct
36 Correct 855 ms 4436 KB Output is correct
37 Correct 859 ms 4472 KB Output is correct
38 Correct 860 ms 4472 KB Output is correct
39 Correct 904 ms 4472 KB Output is correct
40 Correct 1226 ms 5132 KB Output is correct
41 Correct 20 ms 888 KB Output is correct
42 Correct 1205 ms 5132 KB Output is correct
43 Correct 1096 ms 4680 KB Output is correct
44 Correct 1180 ms 4816 KB Output is correct
45 Correct 1771 ms 8184 KB Output is correct
46 Correct 29 ms 1144 KB Output is correct
47 Correct 1702 ms 8256 KB Output is correct
48 Correct 1646 ms 6340 KB Output is correct
49 Correct 1637 ms 7116 KB Output is correct