Submission #244241

# Submission time Handle Problem Language Result Execution time Memory
244241 2020-07-03T10:00:58 Z tleontest1 Wall (IOI14_wall) C++17
Compilation error
0 ms 0 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;
 
#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];
int cev;
PII lazy[li*4];
 
inline void push(int node,int start,int end){
	if(lazy[node].se==0)return ;
	if(lazy[node].se==1){
		tree[node]=max(tree[node],lazy[node].fi);
	}
	if(lazy[node].se==2){
		tree[node]=min(tree[node],lazy[node].fi);
	}
	if(start!=end){
		if(lazy[node*2].se==lazy[node].se && lazy[node].se==1)lazy[node*2].fi=max(lazy[node*2].fi,lazy[node].fi);
		else if(lazy[node].se==1){
			push(node*2,start,mid);
			lazy[node*2]=lazy[node];
		}
		if(lazy[node*2].se==lazy[node].se && lazy[node].se==2)lazy[node*2].fi=min(lazy[node*2].fi,lazy[node].fi);
		else if(lazy[node].se==2){
			push(node*2,start,mid);
			lazy[node*2]=lazy[node];
		}
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		if(lazy[node*2+1].se==lazy[node].se && lazy[node].se==1)lazy[node*2+1].fi=max(lazy[node*2+1].fi,lazy[node].fi);
		else if(lazy[node].se==1){
			push(node*2+1,mid+1,end);
			lazy[node*2+1]=lazy[node];
		}
		if(lazy[node*2+1].se==lazy[node].se && lazy[node].se==2)lazy[node*2+1].fi=min(lazy[node*2+1].fi,lazy[node].fi);
		else if(lazy[node].se==2){
			push(node*2+1,mid+1,end);
			lazy[node*2+1]=lazy[node];
		}
	}
	lazy[node]={0,0};
}
 
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;;
		lazy[node]={val,ty};
		//~ 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]=-1;
		//~ 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;
}
int main()
{
	//~ freopen("at.txt","r",stdin);
	//~ freopen("att.txt","w",stdout);
  int n;
  int k;

  int i, j;  
  int status = 0;

  status = scanf("%d%d", &n, &k);
  assert(status == 2);

  int* op = (int*)calloc(sizeof(int), k);
  int* left = (int*)calloc(sizeof(int), k);
  int* right = (int*)calloc(sizeof(int), k);
  int* height = (int*)calloc(sizeof(int), k);
  int* finalHeight = (int*)calloc(sizeof(int), n);

  for (i = 0; i < k; i++){
    status = scanf("%d%d%d%d", &op[i], &left[i], &right[i], &height[i]);
    assert(status == 4);
  }

  buildWall(n, k, op, left, right, height, finalHeight);

  for (j = 0; j < n; j++)
    printf("%d\n", finalHeight[j]);
  
  return 0;
}

Compilation message

/tmp/ccLemLRG.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccUP3t9q.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status