Submission #289550

# Submission time Handle Problem Language Result Execution time Memory
289550 2020-09-02T18:00:52 Z cheetose Wall (IOI14_wall) C++11
Compilation error
0 ms 0 KB
#include "wall.h"

int mntree[1<<22], mxtree[1<<22], lazy[1<<22];
void propagation(int node, int S, int E)
{
	if (lazy[node] != -1)
	{
		mntree[node] = mxtree[node] = lazy[node];
		if (S != E)
		{
			lazy[2 * node] = lazy[node];
			lazy[2 * node + 1] = lazy[node];
		}
		lazy[node] = -1;
	}
}
void upd(int node, int S, int E, int i, int j, int op, int val)
{
	propagation(node, S, E);
	if (i > E || j < S) return;
	if (j >= E && i <= S)
	{
		if((op==1 && mxtree[node]<=val) || (op==2 && mntree[node]>=val)){
			lazy[node]=val;
			propagation(node,S,E);
			return;
		}
	}
	if(S==E)return;
	upd(2 * node, S, (S + E) / 2, i, j, op, val);
	upd(2 * node + 1, (S + E) / 2 + 1, E, i, j, op, val);
	mntree[node] = min(mntree[2 * node], mntree[2 * node + 1]);
	mxtree[node] = max(mxtree[2 * node], mxtree[2 * node + 1]);
}
int find(int node,int S,int E,int i,int j){
	propagation(node, S, E);
	if (i > E || j < S) return -1;
	if (j >= E && i <= S) return mxtree[node];
	return max(find(node * 2, S, (S + E) / 2, i, j), find(2 * node + 1, (S + E) / 2 + 1, E, i, j));
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	for(int i=0;i<k;i++){
		int o=op[i],l=left[i],r=right[i],x=height[i];
		upd(1,0,n-1,l,r,o,x);
	}
	for(int i=0;i<n;i++){
		finalHeight[i]=find(1,0,n-1,i,i);
	}
}

Compilation message

wall.cpp: In function 'void upd(int, int, int, int, int, int, int)':
wall.cpp:32:17: error: 'min' was not declared in this scope
   32 |  mntree[node] = min(mntree[2 * node], mntree[2 * node + 1]);
      |                 ^~~
wall.cpp:33:17: error: 'max' was not declared in this scope
   33 |  mxtree[node] = max(mxtree[2 * node], mxtree[2 * node + 1]);
      |                 ^~~
wall.cpp: In function 'int find(int, int, int, int, int)':
wall.cpp:39:9: error: 'max' was not declared in this scope
   39 |  return max(find(node * 2, S, (S + E) / 2, i, j), find(2 * node + 1, (S + E) / 2 + 1, E, i, j));
      |         ^~~