답안 #397442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
397442 2021-05-02T08:38:20 Z abdzag Lottery (CEOI18_lot) C++17
100 / 100
653 ms 6264 KB
#include<bits/stdc++.h>

#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
using namespace std;
const long long inf = 1e15;
typedef long long ll;

int main() {
	cin.sync_with_stdio(false);
	ll n, l;
	cin >> n >> l;
	vector<ll> v(n);
	rep(i, 0, n)cin >> v[i];
	short Q;
	cin >> Q;
	vector<short> q(Q);
	rep(i, 0, Q) {
		cin >> q[i];
	}
	vector<vector<short>> res(Q, vector<short>(n - l + 1, -1));
	vector<short> dist(n - l + 1);
	rep(i, 0, n - l + 1) {
		rep(j, 0, l) {
			if (v[i + j] != v[j])dist[i]++;
		}
	}
	rep(i, 0, Q) {
		rep(j, 0, n - l + 1) {
			res[i][0] += (dist[j] <= q[i]);
		}
	}

	rep(i, 1, n - l + 1) {
		vector<int> dist2(l + 1);
		vector<int> prefix(l + 2);
		rrep(j, n - l, 0) {
			dist[j] = dist[j - 1];
		}
		dist[0] = 0;
		rep(j, 0, l) {
			if (v[j] != v[i + j])dist[0]++;
		}
		dist2[dist[0]]++;
		rep(j, 0, n - l) {
			dist[j + 1] -= (v[i - 1] != v[j]);
			dist[j + 1] += (v[i + l - 1] != v[j + l]);
			dist2[dist[j + 1]]++;
		}
		rep(j, 1, l + 2)prefix[j] = prefix[j - 1] + dist2[j - 1];
		rep(j, 0, Q) {
			res[j][i] += prefix[q[j]+1];
		}
		
	}
	trav(vec, res) {
		trav(a, vec)cout << a << " ";
		cout << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 23 ms 356 KB Output is correct
14 Correct 20 ms 460 KB Output is correct
15 Correct 18 ms 368 KB Output is correct
16 Correct 25 ms 408 KB Output is correct
17 Correct 23 ms 460 KB Output is correct
18 Correct 22 ms 408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 545 ms 412 KB Output is correct
2 Correct 528 ms 412 KB Output is correct
3 Correct 569 ms 412 KB Output is correct
4 Correct 561 ms 420 KB Output is correct
5 Correct 318 ms 452 KB Output is correct
6 Correct 499 ms 428 KB Output is correct
7 Correct 306 ms 428 KB Output is correct
8 Correct 415 ms 432 KB Output is correct
9 Correct 508 ms 412 KB Output is correct
10 Correct 570 ms 428 KB Output is correct
11 Correct 42 ms 332 KB Output is correct
12 Correct 378 ms 408 KB Output is correct
13 Correct 379 ms 408 KB Output is correct
14 Correct 408 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 545 ms 412 KB Output is correct
2 Correct 528 ms 412 KB Output is correct
3 Correct 569 ms 412 KB Output is correct
4 Correct 561 ms 420 KB Output is correct
5 Correct 318 ms 452 KB Output is correct
6 Correct 499 ms 428 KB Output is correct
7 Correct 306 ms 428 KB Output is correct
8 Correct 415 ms 432 KB Output is correct
9 Correct 508 ms 412 KB Output is correct
10 Correct 570 ms 428 KB Output is correct
11 Correct 42 ms 332 KB Output is correct
12 Correct 378 ms 408 KB Output is correct
13 Correct 379 ms 408 KB Output is correct
14 Correct 408 ms 432 KB Output is correct
15 Correct 517 ms 420 KB Output is correct
16 Correct 511 ms 412 KB Output is correct
17 Correct 570 ms 408 KB Output is correct
18 Correct 572 ms 332 KB Output is correct
19 Correct 565 ms 408 KB Output is correct
20 Correct 557 ms 412 KB Output is correct
21 Correct 566 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 23 ms 356 KB Output is correct
14 Correct 20 ms 460 KB Output is correct
15 Correct 18 ms 368 KB Output is correct
16 Correct 25 ms 408 KB Output is correct
17 Correct 23 ms 460 KB Output is correct
18 Correct 22 ms 408 KB Output is correct
19 Correct 545 ms 412 KB Output is correct
20 Correct 528 ms 412 KB Output is correct
21 Correct 569 ms 412 KB Output is correct
22 Correct 561 ms 420 KB Output is correct
23 Correct 318 ms 452 KB Output is correct
24 Correct 499 ms 428 KB Output is correct
25 Correct 306 ms 428 KB Output is correct
26 Correct 415 ms 432 KB Output is correct
27 Correct 508 ms 412 KB Output is correct
28 Correct 570 ms 428 KB Output is correct
29 Correct 42 ms 332 KB Output is correct
30 Correct 378 ms 408 KB Output is correct
31 Correct 379 ms 408 KB Output is correct
32 Correct 408 ms 432 KB Output is correct
33 Correct 517 ms 420 KB Output is correct
34 Correct 511 ms 412 KB Output is correct
35 Correct 570 ms 408 KB Output is correct
36 Correct 572 ms 332 KB Output is correct
37 Correct 565 ms 408 KB Output is correct
38 Correct 557 ms 412 KB Output is correct
39 Correct 566 ms 332 KB Output is correct
40 Correct 552 ms 1564 KB Output is correct
41 Correct 79 ms 484 KB Output is correct
42 Correct 579 ms 1548 KB Output is correct
43 Correct 525 ms 1156 KB Output is correct
44 Correct 526 ms 1284 KB Output is correct
45 Correct 636 ms 6084 KB Output is correct
46 Correct 84 ms 944 KB Output is correct
47 Correct 653 ms 6264 KB Output is correct
48 Correct 603 ms 4420 KB Output is correct
49 Correct 639 ms 5068 KB Output is correct