Submission #1056525

# Submission time Handle Problem Language Result Execution time Memory
1056525 2024-08-13T09:52:33 Z parsadox2 Radio Towers (IOI22_towers) C++17
0 / 100
4000 ms 15704 KB
#include <bits/stdc++.h>
#include "towers.h"
 
using namespace std;
 
const int N = 1e5 + 10 , inf = 1e9 , Lg = 17;
 
int n , a[N] , rmxq[N][Lg] , rmnq[N][Lg] , lg2[N];
int val[N] , psum[N];
 
int mn_pos(int aa , int bb)
{
	if(a[aa] < a[bb])
		return aa;
	return bb;
}
 
int mx_pos(int aa , int bb)
{
	if(a[aa] > a[bb])
		return aa;
	return bb;
}
 
void Build()
{
	lg2[1] = 0;
	for(int i = 2 ; i < N ; i++)
		lg2[i] = lg2[i / 2] + 1;
	for(int i = 0 ; i < n ; i++)
		rmnq[i][0] = rmxq[i][0] = i;
	for(int j = 1 ; j < Lg ; j++)
	{
		int len = (1 << j);
		for(int i = 0 ; i + len <= n ; i++)
		{
			rmnq[i][j] = mn_pos(rmnq[i][j - 1] , rmnq[i + len / 2][j - 1]);
			rmxq[i][j] = mx_pos(rmxq[i][j - 1] , rmxq[i + len / 2][j - 1]);
		}
	}
}
 
int Get_mx(int l , int r)
{
	r++;
	int sz = (r - l);  sz = lg2[sz];
	return mx_pos(rmxq[l][sz] , rmxq[r - (1 << sz)][sz]);
}
 
int Get_mn(int l , int r)
{
	r++;
	int sz = (r - l);  sz = lg2[sz];
	return mn_pos(rmnq[l][sz] , rmnq[r - (1 << sz)][sz]);
}
 
void init(int nn , vector <int> vec)
{
	n = nn;
	for(int i = 0 ; i < n ; i++)
		a[i] = vec[i];
	Build();
}
 
int Solve(int l , int r , int d , int val)
{
	int res = 1;
	for(int i = l + 1 ; i + 1 <= r ; i++)
	{
		if(a[i] - d >= a[i - 1] && a[i] - d >= a[i + 1])
			res++;
	}
	return res;
}
 
 
int max_towers(int l , int r , int d)
{
	return Solve(l , r , d , inf);
}
# Verdict Execution time Memory Grader output
1 Incorrect 903 ms 15448 KB 12th lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4026 ms 15704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1401 ms 10840 KB 1st lines differ - on the 1st token, expected: '7197', found: '5748'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6488 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 903 ms 15448 KB 12th lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -