답안 #13703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13703 2015-03-10T09:53:47 Z gs13068 벽 (IOI14_wall) C++
100 / 100
936 ms 51444 KB
#include<algorithm>

struct tree
{
	int min;
	int max;
} t[4444444];

void upd(int i,int s,int e,int l,int r,int op,int height)
{
    if(l<s)l=s;
    if(r>e)r=e;
    if(l>r)return;
    if(l==s&&r==e)
	{
		if(op==1)
		{
			t[i].min = std::max(t[i].min,height);
			t[i].max = std::max(t[i].max,height);
		}
		if(op==2)
		{
			t[i].min = std::min(t[i].min,height);
			t[i].max = std::min(t[i].max,height);
		}
		return;
	}
    t[i*2].max=std::max(t[i*2].max,t[i].min);
    t[i*2].max=std::min(t[i*2].max,t[i].max);
    t[i*2].min=std::max(t[i*2].min,t[i].min);
    t[i*2].min=std::min(t[i*2].min,t[i].max);
    t[i*2+1].max=std::max(t[i*2+1].max,t[i].min);
    t[i*2+1].max=std::min(t[i*2+1].max,t[i].max);
    t[i*2+1].min=std::max(t[i*2+1].min,t[i].min);
    t[i*2+1].min=std::min(t[i*2+1].min,t[i].max);
    t[i].min=0;
    t[i].max=100000;
    upd(i*2,s,(s+e)/2,l,r,op,height);
    upd(i*2+1,(s+e)/2+1,e,l,r,op,height);
}

void get(int i,int s,int e,int finalHeight[])
{
    if(s==e)
	{
		finalHeight[s]=t[i].min;
		return;
	}
    t[i*2].max=std::max(t[i*2].max,t[i].min);
    t[i*2].max=std::min(t[i*2].max,t[i].max);
    t[i*2].min=std::max(t[i*2].min,t[i].min);
    t[i*2].min=std::min(t[i*2].min,t[i].max);
    t[i*2+1].max=std::max(t[i*2+1].max,t[i].min);
    t[i*2+1].max=std::min(t[i*2+1].max,t[i].max);
    t[i*2+1].min=std::max(t[i*2+1].min,t[i].min);
    t[i*2+1].min=std::min(t[i*2+1].min,t[i].max);
    get(i*2,s,(s+e)/2,finalHeight);
    get(i*2+1,(s+e)/2+1,e,finalHeight);
}

void buildWall(int n,int k,int op[],int left[],int right[],int height[],int finalHeight[])
{
	int i;
	for(i=0;i<k;i++)upd(1,0,n-1,left[i],right[i],op[i],height[i]);
	get(1,0,n-1,finalHeight);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 35804 KB Output is correct
2 Correct 0 ms 35804 KB Output is correct
3 Correct 0 ms 35804 KB Output is correct
4 Correct 6 ms 35804 KB Output is correct
5 Correct 7 ms 35804 KB Output is correct
6 Correct 6 ms 35804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 35804 KB Output is correct
2 Correct 162 ms 43628 KB Output is correct
3 Correct 199 ms 39052 KB Output is correct
4 Correct 620 ms 44020 KB Output is correct
5 Correct 403 ms 44020 KB Output is correct
6 Correct 390 ms 44020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 35804 KB Output is correct
2 Correct 0 ms 35804 KB Output is correct
3 Correct 0 ms 35804 KB Output is correct
4 Correct 0 ms 35804 KB Output is correct
5 Correct 0 ms 35804 KB Output is correct
6 Correct 6 ms 35804 KB Output is correct
7 Correct 0 ms 35804 KB Output is correct
8 Correct 174 ms 43628 KB Output is correct
9 Correct 205 ms 39052 KB Output is correct
10 Correct 641 ms 44020 KB Output is correct
11 Correct 417 ms 44020 KB Output is correct
12 Correct 384 ms 44020 KB Output is correct
13 Correct 0 ms 35804 KB Output is correct
14 Correct 183 ms 43628 KB Output is correct
15 Correct 30 ms 36288 KB Output is correct
16 Correct 616 ms 44020 KB Output is correct
17 Correct 441 ms 44020 KB Output is correct
18 Correct 406 ms 44020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 35804 KB Output is correct
2 Correct 0 ms 35804 KB Output is correct
3 Correct 0 ms 35804 KB Output is correct
4 Correct 6 ms 35804 KB Output is correct
5 Correct 0 ms 35804 KB Output is correct
6 Correct 5 ms 35804 KB Output is correct
7 Correct 0 ms 35804 KB Output is correct
8 Correct 182 ms 43628 KB Output is correct
9 Correct 242 ms 39052 KB Output is correct
10 Correct 615 ms 44020 KB Output is correct
11 Correct 432 ms 44020 KB Output is correct
12 Correct 437 ms 44020 KB Output is correct
13 Correct 0 ms 35804 KB Output is correct
14 Correct 225 ms 43628 KB Output is correct
15 Correct 37 ms 36288 KB Output is correct
16 Correct 599 ms 44020 KB Output is correct
17 Correct 426 ms 44020 KB Output is correct
18 Correct 399 ms 44020 KB Output is correct
19 Correct 866 ms 51444 KB Output is correct
20 Correct 844 ms 51444 KB Output is correct
21 Correct 875 ms 51444 KB Output is correct
22 Correct 847 ms 51444 KB Output is correct
23 Correct 897 ms 51444 KB Output is correct
24 Correct 899 ms 51444 KB Output is correct
25 Correct 858 ms 51444 KB Output is correct
26 Correct 860 ms 51444 KB Output is correct
27 Correct 819 ms 51444 KB Output is correct
28 Correct 864 ms 51444 KB Output is correct
29 Correct 936 ms 51444 KB Output is correct
30 Correct 803 ms 51444 KB Output is correct