답안 #847840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
847840 2023-09-10T15:04:35 Z Derek0 벽 (IOI14_wall) C++17
컴파일 오류
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[_], tag[_];
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(p, _) tag[p] = -1;
 
  rep(i, k) {
    if (t[i] == 1) Add(1, 0, n - 1, l[i], r[i], h[i]);
    else Remove(1, 0, n - 1, l[i], r[i], h[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:86:20: error: 'Add' was not declared in this scope
   86 |     if (t[i] == 1) Add(1, 0, n - 1, l[i], r[i], h[i]);
      |                    ^~~
wall.cpp:87:10: error: 'Remove' was not declared in this scope; did you mean 'remove'?
   87 |     else Remove(1, 0, n - 1, l[i], r[i], h[i]);
      |          ^~~~~~
      |          remove
wall.cpp:92:22: error: 'res' was not declared in this scope; did you mean 'rep'?
   92 |   rep(i, n) ans[i] = res[i];
      |                      ^~~
      |                      rep