Submission #645964

# Submission time Handle Problem Language Result Execution time Memory
645964 2022-09-28T11:03:04 Z beaconmc Wall (IOI14_wall) C++14
100 / 100
596 ms 67268 KB
#include "wall.h"
#include <iostream>

typedef int ll;
using namespace std;


#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)



ll lazy[4194304][2];
ll N = 2097152;
ll ans[2097152];

void prop(ll pos, ll mini, ll maxi){
	if (maxi>= lazy[pos][0]){
		lazy[pos][0] = maxi;
		lazy[pos][1] = maxi;
	}else{
		lazy[pos][1] = max(maxi, lazy[pos][1]);
	}

	if (mini<= lazy[pos][1]){
		lazy[pos][0] = mini;
		lazy[pos][1] = mini;
	}else{
		lazy[pos][0] = min(mini, lazy[pos][0]);
	}
}

void update(ll a, ll b, ll op, ll val, ll k=1, ll x=0, ll y=N-1){
	if (b<x || a>y) return;
	if (a<=x && y<=b){
		if(op){
			if (val >= lazy[k][0]){
				lazy[k][0] = val;
				lazy[k][1] = val;
			}else{
				lazy[k][1] = max(lazy[k][1],val);
			}
		}else{
			if (val <= lazy[k][1]){
				lazy[k][0] = val;
				lazy[k][1] = val;
			}else{
				lazy[k][0] = min(lazy[k][0],val);
			}
		}
		return;
	}
    prop(k*2,lazy[k][0],lazy[k][1]);
    prop(k*2+1,lazy[k][0],lazy[k][1]);
    lazy[k][0] = 100001;
    lazy[k][1] = -1;
    ll d = (x+y)/2;
    update(a,b,op,val,2*k,x,d);
    update(a,b,op,val,2*k+1,d+1,y);
    return;

}

void propagate(){
	FOR(i,1,N){
		prop(i*2, lazy[i][0],lazy[i][1]);
        prop(i*2+1, lazy[i][0],lazy[i][1]);
	}
	FOR(i,N,2*N){


        ans[i-N] = (max(min(0,lazy[i][0]), lazy[i][1]));
	}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	FOR(i,0,4194304){
		lazy[i][0] = 100001;
		lazy[i][1] = -1;
	}
	FOR(i,0,k){
		if (op[i]==2) op[i] = 0;
		update(left[i], right[i], op[i], height[i]);
	}
	propagate();
	FOR(i,0,n){
		finalHeight[i] = ans[i];
	}
}

# Verdict Execution time Memory Grader output
1 Correct 32 ms 41324 KB Output is correct
2 Correct 31 ms 41408 KB Output is correct
3 Correct 30 ms 41352 KB Output is correct
4 Correct 34 ms 41420 KB Output is correct
5 Correct 34 ms 41436 KB Output is correct
6 Correct 33 ms 41436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 41300 KB Output is correct
2 Correct 259 ms 49236 KB Output is correct
3 Correct 179 ms 44604 KB Output is correct
4 Correct 418 ms 49744 KB Output is correct
5 Correct 302 ms 50252 KB Output is correct
6 Correct 302 ms 50188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 41196 KB Output is correct
2 Correct 33 ms 41396 KB Output is correct
3 Correct 32 ms 41356 KB Output is correct
4 Correct 34 ms 41440 KB Output is correct
5 Correct 34 ms 41436 KB Output is correct
6 Correct 39 ms 41432 KB Output is correct
7 Correct 30 ms 41284 KB Output is correct
8 Correct 251 ms 49200 KB Output is correct
9 Correct 178 ms 44632 KB Output is correct
10 Correct 424 ms 49792 KB Output is correct
11 Correct 309 ms 50152 KB Output is correct
12 Correct 299 ms 50260 KB Output is correct
13 Correct 29 ms 41300 KB Output is correct
14 Correct 268 ms 49272 KB Output is correct
15 Correct 60 ms 41932 KB Output is correct
16 Correct 495 ms 49996 KB Output is correct
17 Correct 301 ms 50112 KB Output is correct
18 Correct 302 ms 49904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 41320 KB Output is correct
2 Correct 31 ms 41300 KB Output is correct
3 Correct 31 ms 41364 KB Output is correct
4 Correct 34 ms 41436 KB Output is correct
5 Correct 34 ms 41436 KB Output is correct
6 Correct 34 ms 41428 KB Output is correct
7 Correct 29 ms 41300 KB Output is correct
8 Correct 270 ms 49076 KB Output is correct
9 Correct 179 ms 44668 KB Output is correct
10 Correct 410 ms 49744 KB Output is correct
11 Correct 305 ms 50236 KB Output is correct
12 Correct 289 ms 50160 KB Output is correct
13 Correct 30 ms 41320 KB Output is correct
14 Correct 255 ms 49152 KB Output is correct
15 Correct 59 ms 41948 KB Output is correct
16 Correct 488 ms 49980 KB Output is correct
17 Correct 310 ms 49996 KB Output is correct
18 Correct 300 ms 49956 KB Output is correct
19 Correct 580 ms 67240 KB Output is correct
20 Correct 594 ms 64768 KB Output is correct
21 Correct 586 ms 67268 KB Output is correct
22 Correct 593 ms 64752 KB Output is correct
23 Correct 581 ms 64864 KB Output is correct
24 Correct 574 ms 64788 KB Output is correct
25 Correct 575 ms 64844 KB Output is correct
26 Correct 576 ms 67244 KB Output is correct
27 Correct 578 ms 67212 KB Output is correct
28 Correct 596 ms 64844 KB Output is correct
29 Correct 575 ms 64748 KB Output is correct
30 Correct 582 ms 64844 KB Output is correct