Submission #847843

# Submission time Handle Problem Language Result Execution time Memory
847843 2023-09-10T15:06:12 Z Derek0 Wall (IOI14_wall) C++17
100 / 100
514 ms 113576 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 res;

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) {
    res.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];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 102 ms 11204 KB Output is correct
3 Correct 145 ms 7156 KB Output is correct
4 Correct 420 ms 19000 KB Output is correct
5 Correct 202 ms 19656 KB Output is correct
6 Correct 200 ms 18888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 5 ms 1368 KB Output is correct
5 Correct 6 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 101 ms 11260 KB Output is correct
9 Correct 151 ms 7092 KB Output is correct
10 Correct 411 ms 18900 KB Output is correct
11 Correct 213 ms 19908 KB Output is correct
12 Correct 200 ms 18892 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 100 ms 11344 KB Output is correct
15 Correct 28 ms 2776 KB Output is correct
16 Correct 484 ms 19220 KB Output is correct
17 Correct 209 ms 18900 KB Output is correct
18 Correct 210 ms 18968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 4 ms 1372 KB Output is correct
6 Correct 4 ms 1372 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 99 ms 11180 KB Output is correct
9 Correct 144 ms 7120 KB Output is correct
10 Correct 421 ms 18888 KB Output is correct
11 Correct 203 ms 19652 KB Output is correct
12 Correct 199 ms 18900 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 105 ms 11128 KB Output is correct
15 Correct 28 ms 3028 KB Output is correct
16 Correct 489 ms 19160 KB Output is correct
17 Correct 211 ms 18944 KB Output is correct
18 Correct 207 ms 18892 KB Output is correct
19 Correct 506 ms 113124 KB Output is correct
20 Correct 498 ms 102568 KB Output is correct
21 Correct 505 ms 113576 KB Output is correct
22 Correct 504 ms 102392 KB Output is correct
23 Correct 514 ms 102472 KB Output is correct
24 Correct 492 ms 103000 KB Output is correct
25 Correct 496 ms 102316 KB Output is correct
26 Correct 507 ms 113324 KB Output is correct
27 Correct 507 ms 113356 KB Output is correct
28 Correct 500 ms 102724 KB Output is correct
29 Correct 497 ms 102900 KB Output is correct
30 Correct 512 ms 102348 KB Output is correct