Submission #588011

#TimeUsernameProblemLanguageResultExecution timeMemory
588011FatihSolakWall (IOI14_wall)C++17
Compilation error
0 ms0 KiB
#include "wall.h"
#include <bits/stdc++.h>
#define N 100005
using namespace std;
vector<int> st[N];
vector<int> nd[N];
struct SegTreeMAX{
	vector<int> t;
	vector<int> lazy;
	int n;
	SegTree(int size){
		n = size;
		t.assign(4*n,0);
		lazy.assign(4*n,0);
	}
	void push(int v){
		t[v*2] = max(t[v*2],lazy[v]);
		lazy[v*2] = max(lazy[v*2],lazy[v]);

		t[v*2+1] = max(t[v*2+1],lazy[v]);
		lazy[v*2+1] = max(lazy[v*2+1],lazy[v]);

		lazy[v] = 0;
	}
	void upd(int v,int tl,int tr,int l,int r,int val){
		if(tr < l || r <tl){
			return;
		}
		if(l <= tl && tr <= r){
			t[v] = max(t[v],val);
			lazy[v] = max(lazy[v],val);
			return;
		}
		push(v);
		int tm = (tl + tr)/2;
		upd(v*2,tl,tm,l,r,val);
		upd(v*2+1,tm+1,tr,l,r,val);
		t[v] = max(t[v*2],t[v*2+1]);
	}
	int get(int v,int tl,int tr,int pos){
		if(tl == tr){
			return t[v];
		}
		push(v);
		int tm = (tl + tr)/2;
		if(pos <= tm){
			return get(v*2,tl,tm,pos);
		}
		eles return get(v*2+1,tm+1,tr,pos);
	}
	void upd(int l,int r,int val){
		upd(1,0,n-1,l,r,val);
	}
	int get(int pos){
		return get(1,0,n-1,pos);
	}
};
struct SegTreeMIN{
	vector<int> t;
	vector<int> lazy;
	int n;
	SegTree(int size){
		n = size;
		t.assign(4*n,1e9);
		lazy.assign(4*n,1e9);
	}
	void push(int v){
		t[v*2] = min(t[v*2],lazy[v]);
		lazy[v*2] = min(lazy[v*2],lazy[v]);

		t[v*2+1] = min(t[v*2+1],lazy[v]);
		lazy[v*2+1] = min(lazy[v*2+1],lazy[v]);

		lazy[v] = 0;
	}
	void upd(int v,int tl,int tr,int l,int r,int val){
		if(tr < l || r <tl){
			return;
		}
		if(l <= tl && tr <= r){
			t[v] = min(t[v],val);
			lazy[v] = min(lazy[v],val);
			return;
		}
		push(v);
		int tm = (tl + tr)/2;
		upd(v*2,tl,tm,l,r,val);
		upd(v*2+1,tm+1,tr,l,r,val);
		t[v] = min(t[v*2],t[v*2+1]);
	}
	int get(int v,int tl,int tr,int pos){
		if(tl == tr){
			return t[v];
		}
		push(v);
		int tm = (tl + tr)/2;
		if(pos <= tm){
			return get(v*2,tl,tm,pos);
		}
		eles return get(v*2+1,tm+1,tr,pos);
	}
	void upd(int l,int r,int val){
		upd(1,0,n-1,l,r,val);
	}
	int get(int pos){
		return get(1,0,n-1,pos);
	}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
	for(int i = 0;i<n;i++){
		finalHeight[i] = 0;
	}
	if(n * k <= 1e8){
		for(int i = 0;i<k;i++){
			for(int j = left[i];j<=right[i];j++){
				if(op[i] == 1){
					finalHeight[j] = max(finalHeight[j],height[i]);
				}
				else{
					finalHeight[j] = min(finalHeight[j],height[i]);
				}
			}
		}
	}
	else{
		SegTreeMAX tmax(n);
		SegTreeMIN tmin(n);
		for(int i=0;i<k;i++){
			if(op[i] == 1){
				tmax.upd(left[i],right[i],height[i]);
			}
			else{
				tmin.upd(left[i],right[i],height[i]);
			}
		}
		for(int i = 0;i<n;i++){
			finalHeight[i] = min(tmax.get(i),tmin.get(i));
		}
	}
	return;
}

Compilation message (stderr)

wall.cpp:11:2: error: ISO C++ forbids declaration of 'SegTree' with no type [-fpermissive]
   11 |  SegTree(int size){
      |  ^~~~~~~
wall.cpp: In member function 'int SegTreeMAX::SegTree(int)':
wall.cpp:15:2: warning: no return statement in function returning non-void [-Wreturn-type]
   15 |  }
      |  ^
wall.cpp: In member function 'int SegTreeMAX::get(int, int, int, int)':
wall.cpp:49:3: error: 'eles' was not declared in this scope
   49 |   eles return get(v*2+1,tm+1,tr,pos);
      |   ^~~~
wall.cpp: At global scope:
wall.cpp:62:2: error: ISO C++ forbids declaration of 'SegTree' with no type [-fpermissive]
   62 |  SegTree(int size){
      |  ^~~~~~~
wall.cpp: In member function 'int SegTreeMIN::SegTree(int)':
wall.cpp:66:2: warning: no return statement in function returning non-void [-Wreturn-type]
   66 |  }
      |  ^
wall.cpp: In member function 'int SegTreeMIN::get(int, int, int, int)':
wall.cpp:100:3: error: 'eles' was not declared in this scope
  100 |   eles return get(v*2+1,tm+1,tr,pos);
      |   ^~~~
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:126:20: error: no matching function for call to 'SegTreeMAX::SegTreeMAX(int&)'
  126 |   SegTreeMAX tmax(n);
      |                    ^
wall.cpp:7:8: note: candidate: 'SegTreeMAX::SegTreeMAX()'
    7 | struct SegTreeMAX{
      |        ^~~~~~~~~~
wall.cpp:7:8: note:   candidate expects 0 arguments, 1 provided
wall.cpp:7:8: note: candidate: 'SegTreeMAX::SegTreeMAX(const SegTreeMAX&)'
wall.cpp:7:8: note:   no known conversion for argument 1 from 'int' to 'const SegTreeMAX&'
wall.cpp:7:8: note: candidate: 'SegTreeMAX::SegTreeMAX(SegTreeMAX&&)'
wall.cpp:7:8: note:   no known conversion for argument 1 from 'int' to 'SegTreeMAX&&'
wall.cpp:127:20: error: no matching function for call to 'SegTreeMIN::SegTreeMIN(int&)'
  127 |   SegTreeMIN tmin(n);
      |                    ^
wall.cpp:58:8: note: candidate: 'SegTreeMIN::SegTreeMIN()'
   58 | struct SegTreeMIN{
      |        ^~~~~~~~~~
wall.cpp:58:8: note:   candidate expects 0 arguments, 1 provided
wall.cpp:58:8: note: candidate: 'SegTreeMIN::SegTreeMIN(const SegTreeMIN&)'
wall.cpp:58:8: note:   no known conversion for argument 1 from 'int' to 'const SegTreeMIN&'
wall.cpp:58:8: note: candidate: 'SegTreeMIN::SegTreeMIN(SegTreeMIN&&)'
wall.cpp:58:8: note:   no known conversion for argument 1 from 'int' to 'SegTreeMIN&&'
wall.cpp: In member function 'int SegTreeMIN::get(int, int, int, int)':
wall.cpp:101:2: warning: control reaches end of non-void function [-Wreturn-type]
  101 |  }
      |  ^
wall.cpp: In member function 'int SegTreeMAX::get(int, int, int, int)':
wall.cpp:50:2: warning: control reaches end of non-void function [-Wreturn-type]
   50 |  }
      |  ^