Submission #292326

# Submission time Handle Problem Language Result Execution time Memory
292326 2020-09-06T20:41:34 Z VodkaInTheJar Wall (IOI14_wall) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

struct node
{
	int min_val, max_val;
	int lazy; 
    node() {min_val = max_val = 0, lazy = -1;}
};

const int maxn = 2e6 + 3; 

node tr[maxn * 4]; 
void push(int v, int l, int r)
{
	if (tr[v].lazy == -1)
	return;
	
	tr[v].min_val = tr[v].max_val = tr[v].lazy;
	
	if (l != r)
	tr[v * 2].lazy = tr[v * 2 + 1].lazy = tr[v].lazy;
	
	tr[v].lazy = -1; 
}

void merge(int v)
{
	tr[v].min_val = min(tr[v * 2].min_val, tr[v * 2 + 1].min_val);
	tr[v].max_val = max(tr[v * 2].max_val, tr[v * 2 + 1].max_val);
}

void update(int v, int l, int r, int ll, int rr, int val, bool type)
{
	push(v, l, r);
	if (l > rr || r < ll)
	return;
	
	if (l >= ll && r <= rr)
	{
		if (!type)
		{
			if (val <= tr[v].min_val)
			{
				tr[v].lazy = val;
				push(v, l, r);
				
				return;
			}
			
			else
			if (val >= tr[v].max_val)
			return;
		}
		
		else 
		{
			if (val >= tr[v].max_val)
			{
				tr[v].lazy = val;
				push(v, l, r);
				
				return;
			}
			
			else 
			if (val <= tr[v].min_val)
			return;
		}
	}
	
	int mid = (l + r) / 2;
	update(v * 2, l, mid, ll, rr, val, type);
	update(v * 2 + 1, mid + 1, r, ll, rr, val, type);
	
	merge(v);
}

int get(int v, int l, int r, int pos)
{
	push(v, l, r);
	if (l == r)
	return tr[v].min_val;
	
	int mid = (l + r) / 2;
	if (pos <= mid)
	return get(v * 2, l, mid, pos);
	
	else 
	return get(v * 2 + 1, mid + 1, r, pos);
}

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
	for (int i = 0; i < k; i++)
	{
		if (op[i] == 1)
		update(1, 1, n, left[i] + 1, right[i] + 1, height[i], true);
		
		else 
		update(1, 1, n, left[i] + 1, right[i] + 1, height[i], false);
	}
	
	for (int i = 1; i <= n; i++)
	finalHeight[i-1] = get(1, 1, n, i);
}

Compilation message

wall.cpp:2:10: fatal error: grader.h: No such file or directory
    2 | #include "grader.h"
      |          ^~~~~~~~~~
compilation terminated.