Submission #756443

# Submission time Handle Problem Language Result Execution time Memory
756443 2023-06-11T17:18:13 Z Red_Inside Radio Towers (IOI22_towers) C++17
23 / 100
4000 ms 5204 KB
#include "towers.h"
#include <bits/stdc++.h>

//#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
 
using namespace std;
const int maxn=1e5+10,LOG=17,mod=1e9+7;
int block = 650, timer = 0;
const double eps = 1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define bt(i) (1 << (i))
//#define int ll
const long long inf=2e18;
#define y1 yy
#define pii pair <int, int>

int n, a[maxn], t[4*maxn];

void build(int v, int tl, int tr)
{
	if(tl == tr)
	{
		t[v] = a[tl];
		return;
	}
	build(v * 2, tl, (tl + tr) / 2);
	build(v * 2 + 1, (tl + tr) / 2 + 1, tr);
	t[v] = max(t[v * 2], t[v * 2 + 1]);
}

int getmax(int v, int tl, int tr, int l, int r)
{
	if(l <= tl && tr <= r) return t[v];
	if(l > tr || r < tl) return 0;
	return max(getmax(v * 2, tl, (tl + tr) / 2, l, r), 
	getmax(v * 2 + 1, (tl + tr) / 2 + 1, tr, l, r));
}

void init(int N, std::vector<int> H) {
	n = N;
	forn(1, i, n)
	{
		a[i] = H[i-1];
	}
	build(1, 1, n);
}

int Ans;

int max_towers(int l, int r, int d) {
	l++;
	r++;
	if(l == 1 && r == n && Ans != 0) return Ans;
	vector <pii> vec;
	forn(l, i, r)
	{
		vec.pb({a[i], i});
	}
	sort(all(vec));
	set <int> st;
	st.insert(n + 1);
	st.insert(0);
	for(auto it : vec)
	{
		int pos = it.s;
		auto iter = st.lower_bound(pos);
		int r = *iter;
		iter--;
		int l = *iter;
		if((l == 0 || getmax(1, 1, n, l + 1, pos-1) >= a[pos]+d) && 
		(r == n+1 || getmax(1, 1, n, pos+1, r-1) >= a[pos]+d))
		{
			st.insert(pos);
		}
	}
	if(l == 1 && r == n) Ans = (int)st.size() - 2;
	return (int)st.size() - 2;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4064 ms 2456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 18 ms 1752 KB Output is correct
37 Correct 29 ms 2876 KB Output is correct
38 Correct 22 ms 2368 KB Output is correct
39 Correct 32 ms 2600 KB Output is correct
40 Correct 21 ms 2484 KB Output is correct
41 Correct 58 ms 3648 KB Output is correct
42 Correct 16 ms 2476 KB Output is correct
43 Correct 29 ms 2980 KB Output is correct
44 Correct 21 ms 2476 KB Output is correct
45 Correct 20 ms 2484 KB Output is correct
46 Correct 20 ms 2376 KB Output is correct
47 Correct 43 ms 3008 KB Output is correct
48 Correct 29 ms 2748 KB Output is correct
49 Correct 28 ms 2496 KB Output is correct
50 Correct 19 ms 2480 KB Output is correct
51 Correct 29 ms 2880 KB Output is correct
52 Correct 78 ms 4428 KB Output is correct
53 Correct 80 ms 5200 KB Output is correct
54 Correct 103 ms 5152 KB Output is correct
55 Correct 40 ms 3620 KB Output is correct
56 Correct 36 ms 3648 KB Output is correct
57 Correct 63 ms 3532 KB Output is correct
58 Correct 68 ms 3648 KB Output is correct
59 Correct 96 ms 4044 KB Output is correct
60 Correct 91 ms 5204 KB Output is correct
61 Correct 79 ms 4780 KB Output is correct
62 Correct 75 ms 4152 KB Output is correct
63 Correct 81 ms 4896 KB Output is correct
64 Correct 38 ms 3656 KB Output is correct
65 Correct 40 ms 3652 KB Output is correct
66 Correct 41 ms 3608 KB Output is correct
67 Correct 40 ms 3620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4093 ms 5152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 324 ms 1228 KB 2nd lines differ - on the 1st token, expected: '7063', found: '7197'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 2 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 2 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 1 ms 336 KB Output is correct
32 Correct 1 ms 336 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 18 ms 1752 KB Output is correct
37 Correct 29 ms 2876 KB Output is correct
38 Correct 22 ms 2368 KB Output is correct
39 Correct 32 ms 2600 KB Output is correct
40 Correct 21 ms 2484 KB Output is correct
41 Correct 58 ms 3648 KB Output is correct
42 Correct 16 ms 2476 KB Output is correct
43 Correct 29 ms 2980 KB Output is correct
44 Correct 21 ms 2476 KB Output is correct
45 Correct 20 ms 2484 KB Output is correct
46 Correct 20 ms 2376 KB Output is correct
47 Correct 43 ms 3008 KB Output is correct
48 Correct 29 ms 2748 KB Output is correct
49 Correct 28 ms 2496 KB Output is correct
50 Correct 19 ms 2480 KB Output is correct
51 Correct 29 ms 2880 KB Output is correct
52 Correct 78 ms 4428 KB Output is correct
53 Correct 80 ms 5200 KB Output is correct
54 Correct 103 ms 5152 KB Output is correct
55 Correct 40 ms 3620 KB Output is correct
56 Correct 36 ms 3648 KB Output is correct
57 Correct 63 ms 3532 KB Output is correct
58 Correct 68 ms 3648 KB Output is correct
59 Correct 96 ms 4044 KB Output is correct
60 Correct 91 ms 5204 KB Output is correct
61 Correct 79 ms 4780 KB Output is correct
62 Correct 75 ms 4152 KB Output is correct
63 Correct 81 ms 4896 KB Output is correct
64 Correct 38 ms 3656 KB Output is correct
65 Correct 40 ms 3652 KB Output is correct
66 Correct 41 ms 3608 KB Output is correct
67 Correct 40 ms 3620 KB Output is correct
68 Execution timed out 4093 ms 5152 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4064 ms 2456 KB Time limit exceeded
2 Halted 0 ms 0 KB -