답안 #775568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775568 2023-07-06T14:13:56 Z ttamx 벽 (IOI14_wall) C++14
100 / 100
563 ms 102384 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 ta[K],td[K];
	void build(int l,int r,int i){
		ta[i]=0;
		td[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 add(int l,int r,int i,int x,int y,ll v){
		if(y<l||r<x)return;
		v=max(v,ta[i]);
		v=min(v,td[i]);
		if(x<=l&&r<=y)return void(ta[i]=v);
		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){
		if(y<l||r<x)return;
		v=max(v,ta[i]);
		v=min(v,td[i]);
		if(x<=l&&r<=y)return void(td[i]=v);
		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,ll v){
		v=max(v,ta[i]);
		v=min(v,td[i]);
		if(l==r)return v;
		int m=(l+r)/2;
		if(x<=m)return query(l,m,i*2,x,v);
		return query(m+1,r,i*2+1,x,v);
	}
	ll query(int x){
		return query(0,n-1,1,x,0);
	}
}s;

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	::n=n;
	s.build();
	for(int i=k-1;i>=0;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 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 368 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 126 ms 8080 KB Output is correct
3 Correct 98 ms 4716 KB Output is correct
4 Correct 269 ms 12748 KB Output is correct
5 Correct 184 ms 13336 KB Output is correct
6 Correct 175 ms 13220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 1016 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 113 ms 13864 KB Output is correct
9 Correct 100 ms 8432 KB Output is correct
10 Correct 303 ms 21080 KB Output is correct
11 Correct 188 ms 23428 KB Output is correct
12 Correct 175 ms 21916 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 111 ms 13872 KB Output is correct
15 Correct 17 ms 2540 KB Output is correct
16 Correct 282 ms 22676 KB Output is correct
17 Correct 190 ms 22088 KB Output is correct
18 Correct 179 ms 22116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 980 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 110 ms 13864 KB Output is correct
9 Correct 98 ms 8428 KB Output is correct
10 Correct 284 ms 21084 KB Output is correct
11 Correct 185 ms 23484 KB Output is correct
12 Correct 175 ms 21896 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 117 ms 13936 KB Output is correct
15 Correct 17 ms 2508 KB Output is correct
16 Correct 280 ms 22704 KB Output is correct
17 Correct 180 ms 22084 KB Output is correct
18 Correct 180 ms 22020 KB Output is correct
19 Correct 541 ms 102252 KB Output is correct
20 Correct 562 ms 99752 KB Output is correct
21 Correct 539 ms 102348 KB Output is correct
22 Correct 532 ms 99956 KB Output is correct
23 Correct 533 ms 99784 KB Output is correct
24 Correct 548 ms 99752 KB Output is correct
25 Correct 548 ms 99712 KB Output is correct
26 Correct 550 ms 102384 KB Output is correct
27 Correct 563 ms 102308 KB Output is correct
28 Correct 563 ms 99748 KB Output is correct
29 Correct 537 ms 99784 KB Output is correct
30 Correct 530 ms 99760 KB Output is correct