Submission #65485

#TimeUsernameProblemLanguageResultExecution timeMemory
65485theknife2001Wall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include "wall.h" #include <bits/stdc++.h> #define mid (l+r)/2 const int N=2e6+55; int lazy[N*4]; int tree[N*4]; void propagate(int l , int r , int node) { if(lazy[node]==0) return ; tree[node]+=lazy[node]; tree[node]=max(0,tree[node]); if(l!=r) { lazy[node*2]+=lazy[node]; lazy[node*2+1]+=lazy[node]; } lazy[node]=0; } void update(int l , int r , int node , int x , int y , int val) { propagate(l,r,node); if(r<x||l>y) return ; if(x<=l&&r<=y) { lazy[node]+=val; propagate(l,r,node); return ; } update(l,mid,node*2,x,y,val); update(mid+1,r,node*2+1,x,y,val); } int query(int l , int r , int node , int ind) { propagate(l,r,node); if(l==r&&l==ind) return tree[node]; if(ind<=mid) return query(l,mid,node*2,ind); else return query(mid+1,r,node*2+1,ind); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { for(int i=0;i<k;i++) { if(op[i]==2) height[i]*=-1; update(0,n-1,1,right[i],left[i],height[i]); } for(int i=0;i<n;i++) finalHeight[i]=query(0,n-1,1,i); }

Compilation message (stderr)

wall.cpp: In function 'void propagate(int, int, int)':
wall.cpp:14:16: error: 'max' was not declared in this scope
     tree[node]=max(0,tree[node]);
                ^~~
wall.cpp:14:16: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from wall.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~