Submission #847841

# Submission time Handle Problem Language Result Execution time Memory
847841 2023-09-10T15:05:31 Z Derek0 Wall (IOI14_wall) C++17
Compilation error
0 ms 0 KB
#include "wall.h"

#include <bits/stdc++.h>

using namespace std;

#define overload4(a, b, c, d, name, ...) name
#define rep1(i, n) for(ll i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
#define per1(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (b) - 1; i >= a; --i)
#define per3(i, a, b, c) for(ll i = (b) - 1; i >= (a); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1)(__VA_ARGS__)
#define pb emplace_back
#define lb(v,k) (ll) (lower_bound(all(v), (k)) - v.begin())
#define ub(v,k) (ll) (upper_bound(all(v), (k)) - v.begin())
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T, vector<T>, greater<T>>
typedef long long ll;
typedef pair<ll,ll> P;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using vp = vector<P>;
using vvp = vector<vp>;

constexpr int inf = (int) 1e9;

constexpr int _ = (int) 1e7;

ll mx[_], mn[_];
vi ans;

void applyMax(int p, int h) {
  if (mx[p] < h) mx[p] = h;
  if (mn[p] < h) mn[p] = h;
}

void applyMin(int p, int h) {
  if (mx[p] > h) mx[p] = h;
  if (mn[p] > h) mn[p] = h;
}

void push(int p) {
  applyMax(2 * p, mx[p]);
  applyMax(2 * p + 1, mx[p]);
  applyMin(2 * p, mn[p]);
  applyMin(2 * p + 1, mn[p]);
  mx[p] = 0; mn[p] = inf;
}

void modify(int p, int l, int r, int ql, int qr, int h, int t) {
  if (r < ql || l > qr) return;
  if (ql <= l && r <= qr) {
    if (t == 1) applyMax(p, h);
    else applyMin(p, h);
    return;
  }
  int m = (l + r) / 2;
  push(p);
  modify(2 * p, l, m, ql, qr, h, t);
  modify(2 * p + 1, m + 1, r, ql, qr, h, t);
}

void traversal(int p, int l, int r) {
  if (l == r) {
    ans.pb(mx[p]);
    return;
  }
  int m = (l + r) / 2;
  push(p);
  traversal(2 * p, l, m);
  traversal(2 * p + 1, m + 1, r);
}

void buildWall(int n, int k, int t[], int l[], int r[], int h[], int ans[]) {
  rep(i, k) modify(1, 0, n - 1, l[i], r[i], h[i], t[i]);
 
  traversal(1, 0, n - 1);
 
  rep(i, n) ans[i] = res[i];
}

Compilation message

wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:87:22: error: 'res' was not declared in this scope; did you mean 'rep'?
   87 |   rep(i, n) ans[i] = res[i];
      |                      ^~~
      |                      rep