답안 #50261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50261 2018-06-08T15:50:34 Z Just_Solve_The_Problem 벽 (IOI14_wall) C++11
100 / 100
1665 ms 268824 KB
#include <bits/stdc++.h>
#include "wall.h"

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random (rand() ^ (rand() << 15))

using namespace std;

const int N = (int)2e6 + 7;
const int inf = (int)1e9 + 7;

int n, c;

struct T {
  int mn, mx;
  T() {
    mn = 1e5;
    mx = 0;
  }
};

T tree[N * 4];
int* a;

void push(int v, int op, int val) {
  if (op == 1) {
    tree[v].mn = max(tree[v].mn, val);
    tree[v].mx = max(tree[v].mx, val);
  } else if (op == 2) {
    tree[v].mn = min(tree[v].mn, val);
    tree[v].mx = min(tree[v].mx, val);
  }
}

void upd(int v, int tl, int tr, int l, int r, int op, int val) {
  if (tl > r || tr < l) return ;
  if (l <= tl && tr <= r) {
    push(v, op, val);
    a[l] = tree[v].mx;
    return ;
  }
  int mid = (tl + tr) >> 1;
  push(v + v, 1, tree[v].mx);
  push(v + v + 1, 1, tree[v].mx);
  push(v + v, 2, tree[v].mn);
  push(v + v + 1, 2, tree[v].mn);
  tree[v] = T();
  upd(v + v, tl, mid, l, r, op, val);
  upd(v + v + 1, mid + 1, tr, l, r, op, val);
}

void buildWall(int nn, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  n = nn;
  a = finalHeight;
  for (int i = 0; i < k; i++) {
    upd(1, 0, n - 1, left[i], right[i], op[i], height[i]);
  }
  for (int i = 0; i < n; i++) {
    upd(1, 0, n - 1, i, i, 1, 0);
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 62968 KB Output is correct
2 Correct 57 ms 63164 KB Output is correct
3 Correct 55 ms 63164 KB Output is correct
4 Correct 66 ms 63180 KB Output is correct
5 Correct 61 ms 63308 KB Output is correct
6 Correct 55 ms 63308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 63308 KB Output is correct
2 Correct 213 ms 70968 KB Output is correct
3 Correct 280 ms 70968 KB Output is correct
4 Correct 704 ms 71644 KB Output is correct
5 Correct 468 ms 72148 KB Output is correct
6 Correct 409 ms 72228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 72228 KB Output is correct
2 Correct 50 ms 72228 KB Output is correct
3 Correct 54 ms 72228 KB Output is correct
4 Correct 57 ms 72228 KB Output is correct
5 Correct 57 ms 72228 KB Output is correct
6 Correct 58 ms 72228 KB Output is correct
7 Correct 47 ms 72228 KB Output is correct
8 Correct 221 ms 72228 KB Output is correct
9 Correct 250 ms 72228 KB Output is correct
10 Correct 671 ms 72228 KB Output is correct
11 Correct 446 ms 72228 KB Output is correct
12 Correct 405 ms 72356 KB Output is correct
13 Correct 47 ms 72356 KB Output is correct
14 Correct 221 ms 72356 KB Output is correct
15 Correct 91 ms 72356 KB Output is correct
16 Correct 739 ms 82444 KB Output is correct
17 Correct 415 ms 91276 KB Output is correct
18 Correct 469 ms 100292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 100292 KB Output is correct
2 Correct 53 ms 100292 KB Output is correct
3 Correct 55 ms 100292 KB Output is correct
4 Correct 58 ms 100292 KB Output is correct
5 Correct 55 ms 100292 KB Output is correct
6 Correct 56 ms 100292 KB Output is correct
7 Correct 48 ms 100292 KB Output is correct
8 Correct 303 ms 100292 KB Output is correct
9 Correct 264 ms 100292 KB Output is correct
10 Correct 695 ms 100292 KB Output is correct
11 Correct 421 ms 100580 KB Output is correct
12 Correct 450 ms 100692 KB Output is correct
13 Correct 57 ms 100692 KB Output is correct
14 Correct 244 ms 100692 KB Output is correct
15 Correct 85 ms 100692 KB Output is correct
16 Correct 737 ms 110604 KB Output is correct
17 Correct 403 ms 119628 KB Output is correct
18 Correct 434 ms 128820 KB Output is correct
19 Correct 1518 ms 156292 KB Output is correct
20 Correct 1501 ms 164292 KB Output is correct
21 Correct 1443 ms 177204 KB Output is correct
22 Correct 1510 ms 185196 KB Output is correct
23 Correct 1436 ms 195720 KB Output is correct
24 Correct 1559 ms 206100 KB Output is correct
25 Correct 1423 ms 216652 KB Output is correct
26 Correct 1502 ms 229612 KB Output is correct
27 Correct 1424 ms 239928 KB Output is correct
28 Correct 1528 ms 248056 KB Output is correct
29 Correct 1665 ms 258252 KB Output is correct
30 Correct 1417 ms 268824 KB Output is correct