답안 #775541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775541 2023-07-06T13:45:27 Z ttamx 벽 (IOI14_wall) C++14
24 / 100
463 ms 25492 KB
#include "wall.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int K=1<<22;
const ll inf=1e18;

int n;

struct segtree{
	ll t[K],lza[K],lzd[K];
	void build(int l,int r,int i){
		lza[i]=-inf;
		lzd[i]=inf;
		if(l==r)return;
		int m=(l+r)/2;
		build(l,m,i*2);
		build(m+1,r,i*2+1);
	}
	void build(){
		build(0,n-1,1);
	}
	void propagate(int p,int c){
		if(lza[p]!=-inf){
			if(lzd[c]==inf){
				lza[c]=max(lza[c],lza[p]);
			}else if(lzd[c]<=lza[p]){
				lza[c]=max(lza[c],lza[p]);
				lzd[c]=lza[c];
			}
		}
		if(lzd[p]!=inf){
			if(lza[c]==-inf){
				lzd[c]=min(lzd[c],lzd[p]);
			}else if(lza[c]>=lzd[p]){
				lzd[c]=min(lzd[c],lzd[p]);
				lza[c]=lzd[c];
			}
		}
	}
	void pushlz(int l,int r,int i){
		t[i]=max(t[i],lza[i]);
		t[i]=min(t[i],lzd[i]);
		if(l<r){
			propagate(i,i*2);
			propagate(i,i*2+1);
		}
		lza[i]=-inf;
		lzd[i]=inf;
	}
	void add(int l,int r,int i,int x,int y,ll v){
		pushlz(l,r,i);
		if(r<x||y<l)return;
		if(x<=l&&r<=y)return lza[i]=v,pushlz(l,r,i),void();
		int m=(l+r)/2;
		add(l,m,i*2,x,y,v);
		add(m+1,r,i*2+1,x,y,v);
	}
	void add(int x,int y,ll v){
		add(0,n-1,1,x,y,v);
	}
	void del(int l,int r,int i,int x,int y,ll v){
		pushlz(l,r,i);
		if(r<x||y<l)return;
		if(x<=l&&r<=y)return lzd[i]=v,pushlz(l,r,i),void();
		int m=(l+r)/2;
		del(l,m,i*2,x,y,v);
		del(m+1,r,i*2+1,x,y,v);
	}
	void del(int x,int y,ll v){
		del(0,n-1,1,x,y,v);
	}
	ll query(int l,int r,int i,int x){
		pushlz(l,r,i);
		if(l==r)return t[i];
		int m=(l+r)/2;
		if(x<=m)return query(l,m,i*2,x);
		return query(m+1,r,i*2+1,x);
	}
	ll query(int x){
		return query(0,n-1,1,x);
	}
}s;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	::n=n;
	s.build();
	for(int i=0;i<k;i++){
		if(op[i]==1)s.add(left[i],right[i],height[i]);
		else s.del(left[i],right[i],height[i]);
	}
	for(int i=0;i<n;i++)finalHeight[i]=s.query(i);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 108 ms 8656 KB Output is correct
3 Correct 155 ms 8916 KB Output is correct
4 Correct 463 ms 23020 KB Output is correct
5 Correct 249 ms 25492 KB Output is correct
6 Correct 221 ms 23992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Incorrect 2 ms 368 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
3 Incorrect 2 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -