#include "wall.h"
#include "grader.cpp"
#include <vector>
#include <iostream>
const int MAXN = 1e5 + 5;
struct Range
{
int l, r;
Range(){}
Range(int l, int r)
{
this->l = l;
this->r = r;
}
int f(int x)
{
if(x<=l) return l;
if(x>=r) return r;
return x;
}
};
Range Merge(Range first, Range second)
{
if(second.l>=first.r) return Range(second.l, second.l);
if(second.r<=first.l) return Range(second.r, second.r);
if(second.l<=first.l && first.r<=second.r) return Range(first.l, first.r);
if(first.l<=second.l && second.r<=first.r) return Range(second.l, second.r);
if(first.l<=second.l && first.r<=second.r && second.l<=first.r) return Range(second.l, first.r);
if(second.l<=first.l && second.r<=first.r && first.l<=second.r) return Range(first.l, second.r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int ind = 0;ind<n;ind++)
{
Range ans = Range(0, MAXN);
for(int i = 0;i<k;i++)
{
if(ind<left[i] || ind>right[i]) continue;
if(op[i]==1) ans = Merge(ans, Range(height[i], MAXN));
else ans = Merge(ans, Range(0, height[i]));
}
finalHeight[ind] = ans.f(0);
}
}
Compilation message
wall.cpp: In function 'Range Merge(Range, Range)':
wall.cpp:36:1: warning: control reaches end of non-void function [-Wreturn-type]
36 | }
| ^
/tmp/ccmsf4EX.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccexb4S9.o:wall.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status