답안 #298456

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298456 2020-09-12T21:29:03 Z ElyesChaabouni 벽 (IOI14_wall) C++14
24 / 100
352 ms 23544 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define ordered_set tree<int, null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>
#define eps 1e-9
#define MOD1 998244353
#define MOD2 1000000007
#define INV_10 299473306
#define INF 1000000000
#define PI 3.14159265358979323846
using namespace std;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	int p=1;
	while(p <= n)
		p*=2;
	pair<int, int> max_tree[2*p+1], min_tree[2*p+1];
	for(int i = 0; i < 2*p+1; i++)
		max_tree[i]=make_pair(0, -1);
	for(int i = 0; i < 2*p+1; i++)
		min_tree[i]=make_pair(1000000, -1);
	for(int i = 0; i < k; i++)
	{
		int x=left[i]+p, y=right[i]+p;
		if(op[i]==1)
		{
			while(x <= y)
			{
				if(x%2==1)
				{
					max_tree[x]=max(max_tree[x], make_pair(height[i], i));
					x++;
				}
				if(y%2==0)
				{
					max_tree[y]=max(max_tree[y], make_pair(height[i], i));
					y--;
				}
				x/=2;
				y/=2;
			}
		}
		else
		{
			while(x <= y)
			{
				if(x%2==1)
				{
					min_tree[x]=min(min_tree[x], make_pair(height[i], -i));
					x++;
				}
				if(y%2==0)
				{
					min_tree[y]=min(min_tree[y], make_pair(height[i], -i));
					y--;
				}
				x/=2;
				y/=2;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		int x=i+p;
		pair<int, int> ma=make_pair(0, -1), mi=make_pair(1000000, -1);
		while(x >= 1)
		{
			ma=max(ma, max_tree[x]);
			mi=min(mi, min_tree[x]);
			x/=2;
		}
		if(mi.first >= ma.first)
			finalHeight[i]=ma.first;
		else
		{
			if(mi.second*(-1) > ma.second)
				finalHeight[i]=mi.first;
			else
				finalHeight[i]=ma.first;
		}
	}
}
//size
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 171 ms 8184 KB Output is correct
3 Correct 126 ms 4808 KB Output is correct
4 Correct 352 ms 22520 KB Output is correct
5 Correct 235 ms 23544 KB Output is correct
6 Correct 217 ms 22008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -