Submission #826461

# Submission time Handle Problem Language Result Execution time Memory
826461 2023-08-15T15:33:23 Z esomer Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 23060 KB
#include <bits/stdc++.h>
#include "towers.h"

using namespace std;

int N, spec;
vector<int> H, lw;
vector<vector<pair<int, int>>> mn;

pair<int, int> get_mx(int l, int r){
	int k = lw[r - l + 1];
	return max(mn[k][r], mn[k][l + (1 << k) - 1]);
}

void init(int n, vector<int> H1) {
	N = n;
	H = H1;
	spec = 0;
	bool asc = 1;
	for(int i = 1; i < N; i++){
		if(spec == -1) break;
		if(H[i] > H[i-1]){
			if(asc) spec = i;
			else spec = -1;
		}else{
			asc = 0;
		}
	}
	lw.resize(N+1);
	mn.assign(20, vector<pair<int, int>>(N));
	for(int k = 0; k < 20; k++){
		for(int i = 0; i < N; i++){
			if(k == 0) mn[k][i] = {H[i], i};
			else{
				if(i - (1 << (k-1)) < 0) mn[k][i] = mn[k-1][i];
				else{
					mn[k][i] = max(mn[k-1][i], mn[k-1][i - (1 << (k-1))]);
				}
			}
		}
	}
	int pw = 0;
	int curr = 2;
	for(int i = 1; i <= N; i++){
		if(i == curr){
			pw++; curr *= 2;
		}
		lw[i] = pw;
	}
}

pair<int, int> dnc(int L, int R, int D) {
	if(L == R) {
		return {H[L], 1};
	}else if(L > R){
		return {2e9, 0};
	}
	pair<int, int> pr = get_mx(L, R);
	int mx = pr.first;
	int ind = pr.second;
	pair<int, int> ans1 = dnc(ind + 1, R, D);
	pair<int, int> ans2 = dnc(L, ind - 1, D);
	if(ans1.first <= mx - D && ans2.first <= mx - D) return {ans1.first, ans1.second + ans2.second};
	else return min(ans1, ans2);
}

int max_towers(int L, int R, int D) {
	if(spec == -1) return dnc(L, R, D).second;
	else{
		int ans = 1;
		if(L < spec && R > spec) ans++;
		return ans;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 11044 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 668 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 720 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 640 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 720 KB Output is correct
35 Correct 1 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 668 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 720 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 640 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 720 KB Output is correct
35 Correct 1 ms 720 KB Output is correct
36 Correct 13 ms 12068 KB Output is correct
37 Correct 21 ms 18340 KB Output is correct
38 Correct 20 ms 18332 KB Output is correct
39 Correct 20 ms 18332 KB Output is correct
40 Correct 19 ms 18248 KB Output is correct
41 Correct 21 ms 18336 KB Output is correct
42 Correct 20 ms 18360 KB Output is correct
43 Correct 20 ms 18336 KB Output is correct
44 Correct 19 ms 18280 KB Output is correct
45 Correct 20 ms 18248 KB Output is correct
46 Correct 21 ms 18344 KB Output is correct
47 Correct 20 ms 18276 KB Output is correct
48 Correct 20 ms 18248 KB Output is correct
49 Correct 20 ms 18340 KB Output is correct
50 Correct 19 ms 18316 KB Output is correct
51 Correct 21 ms 19504 KB Output is correct
52 Correct 22 ms 18264 KB Output is correct
53 Correct 20 ms 18228 KB Output is correct
54 Correct 20 ms 18336 KB Output is correct
55 Correct 20 ms 18336 KB Output is correct
56 Correct 23 ms 22804 KB Output is correct
57 Correct 21 ms 17608 KB Output is correct
58 Correct 22 ms 18332 KB Output is correct
59 Correct 23 ms 18232 KB Output is correct
60 Correct 21 ms 18332 KB Output is correct
61 Correct 21 ms 18332 KB Output is correct
62 Correct 20 ms 18328 KB Output is correct
63 Correct 20 ms 18256 KB Output is correct
64 Correct 20 ms 18336 KB Output is correct
65 Correct 19 ms 18336 KB Output is correct
66 Correct 26 ms 20912 KB Output is correct
67 Correct 22 ms 23060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4006 ms 18084 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4082 ms 4560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 592 KB Output is correct
3 Correct 1 ms 592 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 592 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 592 KB Output is correct
8 Correct 1 ms 592 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 592 KB Output is correct
11 Correct 1 ms 668 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 592 KB Output is correct
14 Correct 1 ms 592 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 592 KB Output is correct
17 Correct 1 ms 592 KB Output is correct
18 Correct 1 ms 592 KB Output is correct
19 Correct 1 ms 592 KB Output is correct
20 Correct 1 ms 592 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 720 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 1 ms 640 KB Output is correct
29 Correct 1 ms 592 KB Output is correct
30 Correct 1 ms 592 KB Output is correct
31 Correct 1 ms 592 KB Output is correct
32 Correct 1 ms 592 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 720 KB Output is correct
35 Correct 1 ms 720 KB Output is correct
36 Correct 13 ms 12068 KB Output is correct
37 Correct 21 ms 18340 KB Output is correct
38 Correct 20 ms 18332 KB Output is correct
39 Correct 20 ms 18332 KB Output is correct
40 Correct 19 ms 18248 KB Output is correct
41 Correct 21 ms 18336 KB Output is correct
42 Correct 20 ms 18360 KB Output is correct
43 Correct 20 ms 18336 KB Output is correct
44 Correct 19 ms 18280 KB Output is correct
45 Correct 20 ms 18248 KB Output is correct
46 Correct 21 ms 18344 KB Output is correct
47 Correct 20 ms 18276 KB Output is correct
48 Correct 20 ms 18248 KB Output is correct
49 Correct 20 ms 18340 KB Output is correct
50 Correct 19 ms 18316 KB Output is correct
51 Correct 21 ms 19504 KB Output is correct
52 Correct 22 ms 18264 KB Output is correct
53 Correct 20 ms 18228 KB Output is correct
54 Correct 20 ms 18336 KB Output is correct
55 Correct 20 ms 18336 KB Output is correct
56 Correct 23 ms 22804 KB Output is correct
57 Correct 21 ms 17608 KB Output is correct
58 Correct 22 ms 18332 KB Output is correct
59 Correct 23 ms 18232 KB Output is correct
60 Correct 21 ms 18332 KB Output is correct
61 Correct 21 ms 18332 KB Output is correct
62 Correct 20 ms 18328 KB Output is correct
63 Correct 20 ms 18256 KB Output is correct
64 Correct 20 ms 18336 KB Output is correct
65 Correct 19 ms 18336 KB Output is correct
66 Correct 26 ms 20912 KB Output is correct
67 Correct 22 ms 23060 KB Output is correct
68 Execution timed out 4006 ms 18084 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 11044 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -