Submission #373711

#TimeUsernameProblemLanguageResultExecution timeMemory
373711Temmie벽 (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include "wall.h"

#include <bits/stdc++.h>

const int MX = 100000;

struct Node {
	
	Node *l, *r;
	int mn, mx;
	
	Node() : l(nullptr), r(nullptr), min(0), max(MX) { }
	~Node() {
		if (l)
			delete(l);
		if (r)
			delete(r);
	}
	
	void update() {
		if (!l) l = new Node;
		if (!r) r = new Node;
		mn = std::mix(l->mn, r->mn);
		mx = std::min(l->mx, r->mx);
		if (min > max) {
			if (l->mn > r->mx)
				mn = mx = r->mx;
			if (r->mn > l->mx)
				mn = mx = r->mn;
		}
	}
	
};

Node* head = new Node;

void add(int index, int mn, int mx, int left, int right, Node*& node) {
	if (!node)
		node = new Node;
	if (left == right) {
		node->mn = mn;
		node->mx = mx;
		return;
	}
	int mid = (left + right) >> 1;
	if (mid >= index) add(index, mn, mx, left, mid, node->l);
	else add(index, mn, mx, mid + 1, right, node->r);
	node->update();
}

struct Operation {
	int index;
	int mn, mx;
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
	std::vector <std::vector <Operation>> operations(n + 1);
	for (int i = 0; i < k; i++) {
		operations[left[i]].push_back({ i, op[i] ? height[i] : 0, op[i] ? MX : height[i] });
		operations[right[i] + 1].push_back({ i, 0, MX });
	}
	for (int i = 0; i < n; i++) {
		for (const auto& o : operations[i])
			add(o.index, o.mn, o.mx, 0, k - 1, head);
		finalHeight[i] = head->mn;
	}
	delete(head);
}

//int main() {
	
	//int n = 10;
	//int k = 6;
	//int op[6] = { 1, 0, 0, 1, 1, 0 };
	//int left[6] = { 1, 4, 3, 0, 2, 6 };
	//int right[6] = { 8, 9, 6, 5, 2, 7 };
	//int height[6] = { 4, 1, 5, 3, 5, 0 };
	//int finalHeight[10];
	//buildWall(n, k, op, left, right, height, finalHeight);
	//for (int i = 0; i < n; i++)
		//std::cout << finalHeight[i] << " \n"[i == n - 1];
	
//}

Compilation message (stderr)

wall.cpp: In constructor 'Node::Node()':
wall.cpp:12:35: error: class 'Node' does not have any field named 'min'
   12 |  Node() : l(nullptr), r(nullptr), min(0), max(MX) { }
      |                                   ^~~
wall.cpp:12:43: error: class 'Node' does not have any field named 'max'
   12 |  Node() : l(nullptr), r(nullptr), min(0), max(MX) { }
      |                                           ^~~
wall.cpp: In member function 'void Node::update()':
wall.cpp:23:13: error: 'mix' is not a member of 'std'; did you mean 'max'?
   23 |   mn = std::mix(l->mn, r->mn);
      |             ^~~
      |             max
wall.cpp:25:7: error: 'min' was not declared in this scope; did you mean 'std::min'?
   25 |   if (min > max) {
      |       ^~~
      |       std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wall.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
wall.cpp:25:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
   25 |   if (min > max) {
      |             ^~~
      |             std::max
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wall.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: 'std::max' declared here
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~