Submission #70143

#TimeUsernameProblemLanguageResultExecution timeMemory
70143yusufakeWall (IOI14_wall)C++98
100 / 100
1095 ms181500 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...