답안 #743592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743592 2023-05-17T14:14:13 Z josanneo22 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second 
#define int long long
struct node {
	int mx = 0, mn = 0;
};
node tree[2000005];
vector<int> ans(2000005);
void lazy(int pos) {
	tree[2 * pos].mn = min(tree[2 * pos].mn, tree[pos].mn);
	tree[2 * pos].mn = max(tree[2 * pos].mn, tree[pos].mx);
	tree[2 * pos].mx = min(tree[2 * pos].mx, tree[pos].mn);
	tree[2 * pos].mx = max(tree[2 * pos].mx, tree[pos].mx);
	tree[2 * pos+1].mn = min(tree[2 * pos+1].mn, tree[pos].mn);
	tree[2 * pos+1].mn = max(tree[2 * pos+1].mn, tree[pos].mx);
	tree[2 * pos+1].mx = min(tree[2 * pos+1].mx, tree[pos].mn);
	tree[2 * pos+1].mx = max(tree[2 * pos+1].mx, tree[pos].mx); 
	return;
}

void update(int tree_index, int tl, int tr, int l, int r, int type, int heigh) {
	if (tr<l || tl>r) return;
	if (tl <= l && r >= tr) {
		if (type == 1) {
			tree[tree_index].mn = max(tree[tree_index].mn, heigh);
			tree[tree_index].mx = max(tree[tree_index].mx, heigh);
		}
		else {
			tree[tree_index].mn = min(tree[tree_index].mn, heigh);
			tree[tree_index].mx = min(tree[tree_index].mx, heigh);
		}
		return;
	}
	lazy(tree_index);
	tree[tree_index].mn= 2000010;
	tree[tree_index].mx = 0;
	update(tree_index * 2, tl, (tl + tr) / 2, l, r, type, heigh);
	update(tree_index * 2+1, (tl + tr) / 2+1,tr, l, r, type, heigh);
}

void get(int l,int r,int tree_index) {
	if (l == r) {
		ans[l] = tree[tree_index].mn;
	}
	lazy(tree_index);
	get(l, (l + r) / 2, tree_index * 2);
	get((l + r) / 2+1,r, tree_index * 2+1);
}

#include "wall.h"
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	for (int i = 0; i < k; i++) {
		update(1, 0, n - 1, left[i], right[i], op[i], height[i]);
	}
	get(0, n - 1, 1);
	for (int i = 0; i < n; i++) {
		finalHeight[i] = ans[i];
	}
}

Compilation message

/usr/bin/ld: /tmp/ccIbsXiv.o: in function `main':
grader.cpp:(.text.startup+0x133): undefined reference to `buildWall(int, int, int*, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status