Submission #949987

#TimeUsernameProblemLanguageResultExecution timeMemory
949987VinhLuuWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include "wall.h" #include <bits/stdc++.h> //#define int long long #define ll long long #define fi first #define se second #define pb push_back #define all(lmao) lmao.begin(), lmao.end() using namespace std; typedef pair<int,int> pii; typedef tuple<int,int,int> tp; const int N = 2e6 + 5; const ll oo = 1e9; const int K = 5e5; const int mod = 998244353; //const int base = 23; int n, k; struct ST{ int mi[K << 1], mx[K << 1]; void pre(){ for(int i = 1; i <= 2 * k; i ++) mx[i] = 0, mi[i] = oo; } void update(int i,int x){ i += k - 1; if(x == -1){ mi[i] = oo; mx[i] = 0; }else{ mi[i] = x; mx[i] = x; } while(i > 1){ i /= 2; mi[i] = min(mi[i << 1], mi[i << 1|1]); mx[i] = max(mx[i << 1], mx[i << 1|1]); } } int Max(int l,int r){ r++; int ret = 0; for(l += k - 1, r += k - 1; l < r; l /= 2, r /= 2){ if(l & 1) ret = max(ret, mx[l ++]); if(r & 1) ret = max(ret, mx[-- r]); } return ret; } int Min(int l,int r){ r++; int ret = oo; for(l += k - 1, r += k - 1; l < r; l /= 2, r /= 2){ if(l & 1) ret = max(ret, mi[l ++]); if(r & 1) ret = max(ret, mi[-- r]); } return ret; } } add, rm; vector<pii> open[N], close[N]; void buildWall(int _n,int _k, int *op, int *left, int *right, int *height, int &finalHeight[]){ n = _n; k = _k; for(int i = 0; i < k; i ++){ left[i]++; right[i]++; if(op[i] == 1){ open[left[i]].pb({1, height[i]}); close[right[i] + 1].pb({0, i}); }else{ open[left[i]].pb({1, height[i]}); close[right[i] + 1].pb({1, i}); } } add.pre(); rm.pre(); set<int, greater<int>> s; for(int i = 1; i <= n; i ++){ for(auto [t, j] : open[i]){ if(t == 1){ add.update(j + 1, height[j]); s.insert(j + 1); }else rm.update(j + 1, height[j]); } for(auto [t, j] : close[i]){ if(t == 1){ add.update(j + 1, -1); s.erase(j + 1); }else rm.update(j + 1, -1); } int tmp = (*s.begin()); int u = min(add.Max(1, tmp), rm.Min(tmp + 1, k)); finalHeight[i - 1] = u; } } //#define LOCAL #ifdef LOCAL signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } } #endif // LOCAL

Compilation message (stderr)

wall.cpp:73:81: error: declaration of 'finalHeight' as array of references
   73 | void buildWall(int _n,int _k, int *op, int *left, int *right, int *height, int &finalHeight[]){
      |                                                                                 ^~~~~~~~~~~
wall.cpp: In function 'void buildWall(...)':
wall.cpp:74:9: error: '_n' was not declared in this scope; did you mean 'n'?
   74 |     n = _n;
      |         ^~
      |         n
wall.cpp:75:9: error: '_k' was not declared in this scope; did you mean 'k'?
   75 |     k = _k;
      |         ^~
      |         k
wall.cpp:78:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   78 |         left[i]++;
      |               ^
wall.cpp:78:15: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   78 |         left[i]++;
      |         ~~~~~~^
wall.cpp:78:15: error: lvalue required as increment operand
   78 |         left[i]++;
      |               ^
wall.cpp:79:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   79 |         right[i]++;
      |                ^
wall.cpp:79:16: warning: ISO C++ forbids incrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith]
   79 |         right[i]++;
      |         ~~~~~~~^
wall.cpp:79:16: error: lvalue required as increment operand
   79 |         right[i]++;
      |                ^
wall.cpp:80:12: error: 'op' was not declared in this scope; did you mean 'oo'?
   80 |         if(op[i] == 1){
      |            ^~
      |            oo
wall.cpp:81:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   81 |             open[left[i]].pb({1, height[i]});
      |                        ^
wall.cpp:81:17: error: invalid types 'std::vector<std::pair<int, int> > [2000005][std::ios_base&(std::ios_base&)]' for array subscript
   81 |             open[left[i]].pb({1, height[i]});
      |                 ^
wall.cpp:81:34: error: 'height' was not declared in this scope
   81 |             open[left[i]].pb({1, height[i]});
      |                                  ^~~~~~
wall.cpp:82:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |             close[right[i] + 1].pb({0, i});
      |                          ^
wall.cpp:82:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   82 |             close[right[i] + 1].pb({0, i});
      |                   ~~~~~~~~~^~~
wall.cpp:82:18: error: invalid types 'std::vector<std::pair<int, int> > [2000005][std::ios_base& (*)(std::ios_base&)]' for array subscript
   82 |             close[right[i] + 1].pb({0, i});
      |                  ^
wall.cpp:84:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   84 |             open[left[i]].pb({1, height[i]});
      |                        ^
wall.cpp:84:17: error: invalid types 'std::vector<std::pair<int, int> > [2000005][std::ios_base&(std::ios_base&)]' for array subscript
   84 |             open[left[i]].pb({1, height[i]});
      |                 ^
wall.cpp:84:34: error: 'height' was not declared in this scope
   84 |             open[left[i]].pb({1, height[i]});
      |                                  ^~~~~~
wall.cpp:85:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   85 |             close[right[i] + 1].pb({1, i});
      |                          ^
wall.cpp:85:28: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   85 |             close[right[i] + 1].pb({1, i});
      |                   ~~~~~~~~~^~~
wall.cpp:85:18: error: invalid types 'std::vector<std::pair<int, int> > [2000005][std::ios_base& (*)(std::ios_base&)]' for array subscript
   85 |             close[right[i] + 1].pb({1, i});
      |                  ^
wall.cpp:94:35: error: 'height' was not declared in this scope
   94 |                 add.update(j + 1, height[j]);
      |                                   ^~~~~~
wall.cpp:96:36: error: 'height' was not declared in this scope
   96 |             }else rm.update(j + 1, height[j]);
      |                                    ^~~~~~
wall.cpp:106:9: error: 'finalHeight' was not declared in this scope
  106 |         finalHeight[i - 1] = u;
      |         ^~~~~~~~~~~