답안 #260929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260929 2020-08-11T08:12:56 Z my99n 벽 (IOI14_wall) C++14
0 / 100
1 ms 384 KB
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2000100;

struct A {
  int mn, mx;
} seg[MAXN];

int* ans, N;

void tag (int now, int mn, int mx) {
  cerr << "tag" << now << ' ' << mn << ' ' << mx << endl;
  seg[now].mn = min(mx, max(mn, seg[now].mn));
  seg[now].mx = max(mn, min(mx, seg[now].mx));
}

void push (int now, int l, int r) {
  if (l == r) {
    ans[l] = min(seg[now].mx, max(seg[now].mn, ans[l]));
  }
  tag(now*2, seg[now].mn, seg[now].mx);
  tag(now*2+1, seg[now].mn, seg[now].mx);
  seg[now].mn = 0;
  seg[now].mx = 1e9;
}

void build (int now = 1, int l = 1, int r = N) {
  seg[now].mn = 0;
  seg[now].mx = 1e9;
  if (l == r) return;
  int mid = (l+r)/2;
  build(now*2, l, mid);
  build(now*2+1, mid+1, r);
}

void update (int a, int b, int mn, int mx, int now = 1, int l = 1, int r = N) {
  if (r < a or l > b) return;
  if (a <= l and r <= b) return tag(now, mn, mx);
  push(now, l, r);
  int mid = (l+r)/2;
  update(a, b, mn, mx, now*2, l, mid);
  update(a, b, mn, mx, now*2+1, mid+1, r);
}

void dfs (int now = 1, int l = 1, int r = N) {
  push(now, l, r);
  if (l == r) return;
  int mid = (l+r)/2;
  dfs(now*2, l, mid);
  dfs(now*2+1, mid+1, r);
}

void buildWall(int n, int k, int op[], int l[], int r[], int h[], int finalHeight[]){
	ans = finalHeight;
	N = n;
	build();
	for(int i = 0; i < k; i++) {
		if(op[i] == 1) update(l[i], r[i], h[i], 1e9);
		else if(op[i] == 2) update(l[i], r[i], 0, h[i]);
	}
	dfs();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -