Submission #972863

# Submission time Handle Problem Language Result Execution time Memory
972863 2024-05-01T09:14:10 Z sleepntsheep Wall (IOI14_wall) C
100 / 100
563 ms 66612 KB
#pragma GCC optimize("O2,unroll-loops")
#include "wall.h"

#define MAX_N 2000000

int lo(int a,int b){return a>b?b:a;}
int hi(int a,int b){return a<b?b:a;}

int min[MAX_N<<2], max[MAX_N<<2];

void apply(int v,int kl,int kh)
{
    min[v]=hi(kh,lo(min[v],kl));
    max[v]=hi(kh,lo(max[v],kl));
}

void push(int v,int l,int r)
{
    if(l==r)return;
    apply(v<<1,min[v],max[v]);
    apply(v<<1|1,min[v],max[v]);
    min[v]=1e9,max[v]=-1e9;
}

void upd(int v,int l,int r,int x,int y,int kl,int kh)
{
    push(v,l,r);
    if(r<x||y<l)return;
    if(x<=l&&r<=y){apply(v,kl,kh);return;}
    upd(v<<1,l,l+(r-l)/2,x,y,kl,kh),upd(v<<1|1,l+(r-l)/2+1,r,x,y,kl,kh);
}

void build(int v,int l,int r)
{
    if(l==r)min[v]=max[v]=0;
    else build(v<<1,l,l+(r-l)/2),build(v<<1|1,l+(r-l)/2+1,r);
}

void ans(int v,int l,int r,int *o)
{
    push(v,l,r);
    if(l==r){o[l]=min[v];return;}
    ans(v<<1,l,l+(r-l)/2,o),ans(v<<1|1,l+(r-l)/2+1,r,o);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
    build(1,0,n-1);
    for(int i=0;i<k;++i) upd(1,0,n-1,left[i],right[i],op[i]==1?1e9:height[i],op[i]==2?-1e9:height[i]);
    ans(1,0,n-1,finalHeight);
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2392 KB Output is correct
2 Correct 3 ms 2548 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 4 ms 2652 KB Output is correct
5 Correct 6 ms 2816 KB Output is correct
6 Correct 5 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2728 KB Output is correct
2 Correct 106 ms 13556 KB Output is correct
3 Correct 137 ms 7504 KB Output is correct
4 Correct 444 ms 19228 KB Output is correct
5 Correct 257 ms 19780 KB Output is correct
6 Correct 237 ms 19184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 2 ms 2492 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 5 ms 2652 KB Output is correct
5 Correct 4 ms 2652 KB Output is correct
6 Correct 4 ms 2676 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 126 ms 13344 KB Output is correct
9 Correct 136 ms 8092 KB Output is correct
10 Correct 394 ms 19016 KB Output is correct
11 Correct 248 ms 19784 KB Output is correct
12 Correct 251 ms 18860 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 105 ms 13136 KB Output is correct
15 Correct 22 ms 3676 KB Output is correct
16 Correct 392 ms 19196 KB Output is correct
17 Correct 239 ms 19028 KB Output is correct
18 Correct 243 ms 18904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 5 ms 2676 KB Output is correct
5 Correct 4 ms 2900 KB Output is correct
6 Correct 5 ms 2904 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 103 ms 13152 KB Output is correct
9 Correct 136 ms 8124 KB Output is correct
10 Correct 396 ms 19008 KB Output is correct
11 Correct 244 ms 19776 KB Output is correct
12 Correct 254 ms 19164 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 103 ms 13232 KB Output is correct
15 Correct 23 ms 3676 KB Output is correct
16 Correct 391 ms 19508 KB Output is correct
17 Correct 237 ms 19052 KB Output is correct
18 Correct 238 ms 18928 KB Output is correct
19 Correct 548 ms 66220 KB Output is correct
20 Correct 541 ms 63640 KB Output is correct
21 Correct 544 ms 66344 KB Output is correct
22 Correct 547 ms 63760 KB Output is correct
23 Correct 539 ms 63772 KB Output is correct
24 Correct 545 ms 63668 KB Output is correct
25 Correct 532 ms 63888 KB Output is correct
26 Correct 563 ms 66236 KB Output is correct
27 Correct 557 ms 66612 KB Output is correct
28 Correct 547 ms 58412 KB Output is correct
29 Correct 546 ms 58528 KB Output is correct
30 Correct 532 ms 58436 KB Output is correct