Submission #70143

# Submission time Handle Problem Language Result Execution time Memory
70143 2018-08-22T11:48:53 Z yusufake Wall (IOI14_wall) C++
100 / 100
1095 ms 181500 KB
#include<bits/stdc++.h>
using namespace std;
#include "wall.h"

#define N 2000006
#define tm (tl+tr >> 1)

int A[N<<2],B[N<<2],T[N];
void put1(int v, int x){
    A[v] = max(A[v],x);
    B[v] = max(B[v] , A[v]);
}
void put2(int v, int x){
    B[v] = min(B[v],x);
    A[v] = min(A[v] , B[v]);
}

void push(int v){
    put1(v+v,A[v]); put1(v+v+1,A[v]); A[v] = 0;
    put2(v+v,B[v]); put2(v+v+1,B[v]); B[v] = N;
}

void f(int v, int tl, int tr){
    if(tl == tr) { T[tl] = A[v]; return; }
    push(v); f(v+v,tl,tm); f(v+v+1,tm+1,tr);
}

void up(int v, int tl, int tr, int l, int r, int x, int h){
    if(tl > r || tr < l) return;
    if(tl >= l && tr <= r){
        if(h == 1) put1(v,x);
        else put2(v,x);
        return;
    }
    push(v); up(v+v,tl,tm,l,r,x,h); up(v+v+1,tm+1,tr,l,r,x,h);
}

void buildWall(int n, int k, int *op, int *lef, int *rig, int *hei, int *ans){
    memset(B,22,sizeof B);
    int i;
    for(i=0;i<k;i++)
        up(1,0,n-1,lef[i],rig[i],hei[i],op[i]);
    f(1,0,n-1);
    for(i=0;i<n;i++) ans[i] = T[i];
}

Compilation message

wall.cpp: In function 'void f(int, int, int)':
wall.cpp:6:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl+tr >> 1)
             ~~^~
wall.cpp:25:23: note: in expansion of macro 'tm'
     push(v); f(v+v,tl,tm); f(v+v+1,tm+1,tr);
                       ^~
wall.cpp:6:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl+tr >> 1)
             ~~^~
wall.cpp:25:36: note: in expansion of macro 'tm'
     push(v); f(v+v,tl,tm); f(v+v+1,tm+1,tr);
                                    ^~
wall.cpp: In function 'void up(int, int, int, int, int, int, int)':
wall.cpp:6:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl+tr >> 1)
             ~~^~
wall.cpp:35:24: note: in expansion of macro 'tm'
     push(v); up(v+v,tl,tm,l,r,x,h); up(v+v+1,tm+1,tr,l,r,x,h);
                        ^~
wall.cpp:6:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
 #define tm (tl+tr >> 1)
             ~~^~
wall.cpp:35:46: note: in expansion of macro 'tm'
     push(v); up(v+v,tl,tm,l,r,x,h); up(v+v+1,tm+1,tr,l,r,x,h);
                                              ^~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 31608 KB Output is correct
2 Correct 33 ms 31848 KB Output is correct
3 Correct 29 ms 31856 KB Output is correct
4 Correct 37 ms 32348 KB Output is correct
5 Correct 36 ms 32472 KB Output is correct
6 Correct 33 ms 32512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 32512 KB Output is correct
2 Correct 235 ms 45896 KB Output is correct
3 Correct 261 ms 45896 KB Output is correct
4 Correct 670 ms 55072 KB Output is correct
5 Correct 400 ms 55488 KB Output is correct
6 Correct 362 ms 55588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 55588 KB Output is correct
2 Correct 29 ms 55588 KB Output is correct
3 Correct 29 ms 55588 KB Output is correct
4 Correct 44 ms 55588 KB Output is correct
5 Correct 33 ms 55588 KB Output is correct
6 Correct 34 ms 55588 KB Output is correct
7 Correct 26 ms 55588 KB Output is correct
8 Correct 219 ms 55588 KB Output is correct
9 Correct 272 ms 55588 KB Output is correct
10 Correct 734 ms 55588 KB Output is correct
11 Correct 414 ms 55672 KB Output is correct
12 Correct 415 ms 55672 KB Output is correct
13 Correct 30 ms 55672 KB Output is correct
14 Correct 260 ms 55672 KB Output is correct
15 Correct 64 ms 55672 KB Output is correct
16 Correct 684 ms 55672 KB Output is correct
17 Correct 414 ms 55672 KB Output is correct
18 Correct 434 ms 55672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 55672 KB Output is correct
2 Correct 36 ms 55672 KB Output is correct
3 Correct 29 ms 55672 KB Output is correct
4 Correct 36 ms 55672 KB Output is correct
5 Correct 37 ms 55672 KB Output is correct
6 Correct 33 ms 55672 KB Output is correct
7 Correct 25 ms 55672 KB Output is correct
8 Correct 280 ms 55672 KB Output is correct
9 Correct 284 ms 55672 KB Output is correct
10 Correct 638 ms 55672 KB Output is correct
11 Correct 408 ms 55672 KB Output is correct
12 Correct 373 ms 55672 KB Output is correct
13 Correct 27 ms 55672 KB Output is correct
14 Correct 308 ms 55672 KB Output is correct
15 Correct 69 ms 55672 KB Output is correct
16 Correct 790 ms 55672 KB Output is correct
17 Correct 378 ms 55672 KB Output is correct
18 Correct 413 ms 55672 KB Output is correct
19 Correct 856 ms 95248 KB Output is correct
20 Correct 868 ms 103248 KB Output is correct
21 Correct 948 ms 114944 KB Output is correct
22 Correct 924 ms 114944 KB Output is correct
23 Correct 1095 ms 114944 KB Output is correct
24 Correct 820 ms 122828 KB Output is correct
25 Correct 830 ms 133084 KB Output is correct
26 Correct 852 ms 145892 KB Output is correct
27 Correct 941 ms 155556 KB Output is correct
28 Correct 938 ms 162696 KB Output is correct
29 Correct 920 ms 172104 KB Output is correct
30 Correct 957 ms 181500 KB Output is correct