답안 #244252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244252 2020-07-03T11:42:41 Z tleontest1 벽 (IOI14_wall) C++14
100 / 100
1726 ms 105636 KB
#include "wall.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< int,int > PII;
typedef pair< int,PII > PIII;
 
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const int inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 2000005;
const lo mod = 1000000007;
 
int flag,t,m,tree[li*4],lazy1[li*4],lazy[li*4];
int cev;
//~ PIII lazy[li*4];
 
inline void push(int node,int start,int end){
	{tree[node]=max(tree[node],lazy[node]);}
	{tree[node]=min(tree[node],lazy1[node]);}
	if(start!=end){
		lazy[node*2] = max(lazy[node*2],lazy[node]),lazy1[node*2] = max(lazy1[node*2],lazy[node]);
        lazy[node*2+1] = max(lazy[node*2+1],lazy[node]),lazy1[node*2+1] = max(lazy1[node*2+1],lazy[node]);
        lazy1[node*2] = min(lazy1[node*2],lazy1[node]),lazy[node*2] = min(lazy[node*2],lazy1[node]);
        lazy1[node*2+1] = min(lazy1[node*2+1],lazy1[node]),lazy[node*2+1] = min(lazy[node*2+1],lazy1[node]);
	}
	lazy[node]=-inf;
	lazy1[node]=inf;
}
 
inline void update(int node,int start,int end,int l,int r,int val,int ty){
	//~ push1(node,start,end);
	push(node,start,end);
	if(start>end || start>r || end<l)return ;
	
	if(start>=l && end<=r){
		//~ cout<<query1(1,1,m,start,start)<<" : : "<<query1(1,1,m,end,end)<<" : : "<<start<<" ; : "<<end<<endl;;
		if(ty==1)lazy[node]=max(val,lazy[node]);
		if(ty==2)lazy1[node]=min(lazy1[node],val);
		//~ push1(node,start,end);
		push(node,start,end);
		return ;
	}
	update(node*2,start,mid,l,r,val,ty);
	update(node*2+1,mid+1,end,l,r,val,ty);
	tree[node]=max(tree[node*2],tree[node*2+1]);
}
 
inline int query(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l)return 0;
	push(node,start,end);
	//~ push1(node,start,end);
	if(start>=l && end<=r)return tree[node];
	return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}
 
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	m=n;
	for(int i=1;i<=4*n;i++){
		//~ tree1[i]=inf;
		lazy1[i]=inf;
		//~ tree[i]=-1;
		lazy[i]=-inf;
		//~ tree2[i]=inf;
		//~ lazy2[i]=inf;
	}
	//~ int mn=inf;
	//~ for(int i=k-1;i>=0;i--){
		//~ if(op[i]==1)
		//~ update2(1,1,n,left[i],right[i],i);
	//~ }
	//~ FOR{
		//~ int at=query2(1,1,n,i,i);
		//~ cout<<i<<" : : "<<at<<endl;
		//~ if(at==inf)continue;
		//~ v[at].pb(i);
	//~ }
	for(int i=0;i<k;i++){
		//~ cout<<height[i]<<endl;
		//~ if(op[i]==2){
			//~ update1(1,1,n,left[i]+1,right[i]+1,height[i]);
			//~ continue;
		//~ }
		//~ cout<<"**\n";
		update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]);
		//~ for(int j=0;j<(int)v[i].size();j++){
			//~ cout<<v[i][j]<<endl;
		//~ }
		//~ if(op[i]==2)update1(1,1,n,left[i]+1,right[i]+1,height[i]);
		//~ update2(1,1,n,left[i]+1,right[i]+1,i);
	}
	FOR finalHeight[i-1]=query(1,1,n,i,i);
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 6 ms 512 KB Output is correct
4 Correct 13 ms 896 KB Output is correct
5 Correct 13 ms 896 KB Output is correct
6 Correct 13 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 174 ms 8312 KB Output is correct
3 Correct 274 ms 4600 KB Output is correct
4 Correct 797 ms 13016 KB Output is correct
5 Correct 455 ms 13432 KB Output is correct
6 Correct 441 ms 13432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 14 ms 896 KB Output is correct
5 Correct 12 ms 1024 KB Output is correct
6 Correct 13 ms 896 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 175 ms 8184 KB Output is correct
9 Correct 261 ms 4600 KB Output is correct
10 Correct 786 ms 13048 KB Output is correct
11 Correct 464 ms 13516 KB Output is correct
12 Correct 455 ms 13560 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 185 ms 8156 KB Output is correct
15 Correct 49 ms 1784 KB Output is correct
16 Correct 803 ms 13268 KB Output is correct
17 Correct 467 ms 13308 KB Output is correct
18 Correct 466 ms 13260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 14 ms 896 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
6 Correct 13 ms 1024 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 174 ms 8184 KB Output is correct
9 Correct 272 ms 4728 KB Output is correct
10 Correct 793 ms 13032 KB Output is correct
11 Correct 455 ms 13444 KB Output is correct
12 Correct 459 ms 13432 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 177 ms 8184 KB Output is correct
15 Correct 48 ms 1784 KB Output is correct
16 Correct 787 ms 13280 KB Output is correct
17 Correct 459 ms 13176 KB Output is correct
18 Correct 467 ms 13176 KB Output is correct
19 Correct 1681 ms 105496 KB Output is correct
20 Correct 1628 ms 102916 KB Output is correct
21 Correct 1686 ms 105272 KB Output is correct
22 Correct 1664 ms 103032 KB Output is correct
23 Correct 1657 ms 103024 KB Output is correct
24 Correct 1689 ms 102864 KB Output is correct
25 Correct 1643 ms 102908 KB Output is correct
26 Correct 1674 ms 105396 KB Output is correct
27 Correct 1726 ms 105636 KB Output is correct
28 Correct 1655 ms 103032 KB Output is correct
29 Correct 1620 ms 102904 KB Output is correct
30 Correct 1649 ms 102880 KB Output is correct