Submission #349318

#TimeUsernameProblemLanguageResultExecution timeMemory
349318David_MWall (IOI14_wall)C++14
Compilation error
0 ms0 KiB
#include "wall.h" #include <bits/stdc++.h> #define pb push_back using namespace std; struct uwu{int type, height, time; uwu (int x, int y, int z){time=z,type=x,height=y;} }; vector<uwu> v[1<<20]; int T[2][1<<23], M[2]; void build (int x=1, int l=0, int r=n){ if(l==r){ T[1][x]=(!!l)*INF; return; } T[1][x]=min(T[1][x<<1], T[1][x<<1|1]); } void upd(uwu a, int x=1, int l=0, int r=n){ if(l==r){ T[a.type][x]=a.height; return; } int mid=l+r>>1; if(a.time<mid) upd(a, x<<1, l, mid); else upd(a, x<<1|1, mid+1, r); T[0][x]=max(T[0][x<<1], T[0][x<<1|1]); T[1][x]=min(T[1][x<<1], T[1][x<<1|1]); } int get(int x=1, int l=0, int r=n){ if(l==r) return (T[0][x]==M[0])?M[1]:M[0]; int m[]={max(M[0], T[0][x<<1|1]), min(M[1], T[1][x<<1|1])}, mid=l+r>>1; if(m[1]>m[0])M[0]=m[0], M[1]=m[1], get(x<<1, l, mid); else get(x<<1|1, mid+1, r); } void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){ build(); for(int i=0; i<k; i++){ op[i]--; v[left[i]].pb({i+1, op[i], height[i]}); v[right[i]+1].pb({i+1, op[i], op[i]==1?0:INF}); } for (int i=0; i<n; i++){ for (int j=0; j<v[i].size(); j++) upd(v[i][j]); M[0]=0; M[1]=INF; finalHeight[i]=get(); } }

Compilation message (stderr)

wall.cpp:10:37: error: 'n' was not declared in this scope
   10 | void build (int x=1, int l=0, int r=n){
      |                                     ^
wall.cpp: In function 'void build(int, int, int)':
wall.cpp:11:26: error: 'INF' was not declared in this scope
   11 |  if(l==r){ T[1][x]=(!!l)*INF; return; }
      |                          ^~~
wall.cpp: At global scope:
wall.cpp:15:41: error: 'n' was not declared in this scope
   15 | void upd(uwu a, int x=1, int l=0, int r=n){
      |                                         ^
wall.cpp: In function 'void upd(uwu, int, int, int)':
wall.cpp:17:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |  int mid=l+r>>1;
      |          ~^~
wall.cpp: At global scope:
wall.cpp:25:33: error: 'n' was not declared in this scope
   25 | int get(int x=1, int l=0, int r=n){
      |                                 ^
wall.cpp: In function 'int get(int, int, int)':
wall.cpp:27:67: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |  int m[]={max(M[0], T[0][x<<1|1]), min(M[1], T[1][x<<1|1])}, mid=l+r>>1;
      |                                                                  ~^~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:38:44: error: 'INF' was not declared in this scope
   38 |   v[right[i]+1].pb({i+1, op[i], op[i]==1?0:INF});
      |                                            ^~~
wall.cpp:38:48: error: no matching function for call to 'std::vector<uwu>::push_back(<brace-enclosed initializer list>)'
   38 |   v[right[i]+1].pb({i+1, op[i], op[i]==1?0:INF});
      |                                                ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from wall.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = uwu; _Alloc = std::allocator<uwu>; std::vector<_Tp, _Alloc>::value_type = uwu]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const uwu&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = uwu; _Alloc = std::allocator<uwu>; std::vector<_Tp, _Alloc>::value_type = uwu]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<uwu>::value_type&&' {aka 'uwu&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
wall.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<uwu>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int j=0; j<v[i].size(); j++) upd(v[i][j]);
      |                 ~^~~~~~~~~~~~
wall.cpp:43:16: error: 'INF' was not declared in this scope
   43 |   M[0]=0; M[1]=INF; finalHeight[i]=get();
      |                ^~~
wall.cpp: In function 'int get(int, int, int)':
wall.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      | ^