Submission #596111

#TimeUsernameProblemLanguageResultExecution timeMemory
596111nekiWall (IOI14_wall)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define vc vector using namespace std; const int mn=2000000; int tl[4 * mn], tr[4 * mn]; void apply(int no, int m, int M){ if(tr[no]<=m) tl[no]=tr[no]=m; else if(M<=tl[no]) tl[no]=tr[no]=M; else tl[no]=max(tl[no], m), tr[no]=min(tr[no], M); } void push(int no){ apply(no * 2 +1, tl[no], tr[no]); apply(no * 2 +2, tl[no], tr[no]); tl[no]=0, tr[no]=INT_MAX; } void update(int ql, int qr, int m, int M, int l, int r, int no){ if(ql==l and qr==r) apply(no, m, M); else{ int mid=(l+r)/2; push(no); if(qr<=mid) update(ql, qr, m, M, l, mid, no * 2 +1); else if(mid<ql) update(ql, qr, m, M, mid+1, r, no * 2 +2); else update(ql, mid, m, M, l, mid, no * 2 + 1), update(mid+1, qr, m, M, mid+1, r, no * 2 +2); } } void build(int l, int r, int no, int[] ans){ if(l==r) ans[l]=tl[no]; else{ int mid=(l+r)/2; push(no); build(l, mid, no * 2 +1, ans); build(mid+1, r, no * 2 + 2, ans); } } void buildWall(int n, int k, vc<int> op, int[] ql, int[] qr, int[] h, int[] ans){ for(int i=0;i<k;++i){ if(op[i]==1) update(ql[i], qr[i], h[i], INT_MAX, 0, n-1, 0); if(op[i]==2) update(ql[i], qr[i], 0, h[i], 0, n-1, 0); } build(0, n-1, 0, ans); }

Compilation message (stderr)

wall.cpp:29:40: error: expected ',' or '...' before 'ans'
   29 | void build(int l, int r, int no, int[] ans){
      |                                        ^~~
wall.cpp: In function 'void build(int, int, int, int*)':
wall.cpp:30:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |     if(l==r) ans[l]=tl[no];
      |              ^~~
      |              abs
wall.cpp:34:34: error: 'ans' was not declared in this scope; did you mean 'abs'?
   34 |         build(l, mid, no * 2 +1, ans);
      |                                  ^~~
      |                                  abs
wall.cpp: At global scope:
wall.cpp:39:48: error: expected ',' or '...' before 'ql'
   39 | void buildWall(int n, int k, vc<int> op, int[] ql, int[] qr, int[] h, int[] ans){
      |                                                ^~
wall.cpp: In function 'void buildWall(int, int, std::vector<int>, int*)':
wall.cpp:41:29: error: 'ql' was not declared in this scope; did you mean 'tl'?
   41 |         if(op[i]==1) update(ql[i], qr[i], h[i], INT_MAX, 0, n-1, 0);
      |                             ^~
      |                             tl
wall.cpp:41:36: error: 'qr' was not declared in this scope; did you mean 'tr'?
   41 |         if(op[i]==1) update(ql[i], qr[i], h[i], INT_MAX, 0, n-1, 0);
      |                                    ^~
      |                                    tr
wall.cpp:41:43: error: 'h' was not declared in this scope
   41 |         if(op[i]==1) update(ql[i], qr[i], h[i], INT_MAX, 0, n-1, 0);
      |                                           ^
wall.cpp:42:29: error: 'ql' was not declared in this scope; did you mean 'tl'?
   42 |         if(op[i]==2) update(ql[i], qr[i], 0, h[i], 0, n-1, 0);
      |                             ^~
      |                             tl
wall.cpp:42:36: error: 'qr' was not declared in this scope; did you mean 'tr'?
   42 |         if(op[i]==2) update(ql[i], qr[i], 0, h[i], 0, n-1, 0);
      |                                    ^~
      |                                    tr
wall.cpp:42:46: error: 'h' was not declared in this scope
   42 |         if(op[i]==2) update(ql[i], qr[i], 0, h[i], 0, n-1, 0);
      |                                              ^
wall.cpp:44:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |     build(0, n-1, 0, ans);
      |                      ^~~
      |                      abs