# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
68620 | | Vahan | 벽 (IOI14_wall) | C++17 | | 1326 ms | 186700 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wall.h"
#include<algorithm>
using namespace std;
pair<int,int> t[17000000];
void update(int l,int r,int L,int R,int v,int a,int b)
{
if(l>r)
return;
if(l==L && r==R)
{
if(b==1)
{
t[v].first=max(a,t[v].first);
t[v].second=max(a,t[v].second);
}
if(b==2)
{
t[v].first=min(a,t[v].first);
t[v].second=min(a,t[v].second);
}
}
else
{
t[2*v].first=min(max(t[2*v].first,t[v].first),t[v].second);
t[2*v].second=min(max(t[2*v].second,t[v].first),t[v].second);
t[2*v+1].first=min(max(t[2*v+1].first,t[v].first),t[v].second);
t[2*v+1].second=min(max(t[2*v+1].second,t[v].first),t[v].second);
t[v].first=0;
t[v].second=1e5+10;
int mid=(L+R)/2;
update(l,min(mid,r),L,mid,2*v,a,b);
update(max(l,mid+1),r,mid+1,R,2*v+1,a,b);
}
}
int get(int l,int r,int v,int a)
{
if(l==r)
return t[v].first;
t[2*v].first=min(max(t[2*v].first,t[v].first),t[v].second);
t[2*v].second=min(max(t[2*v].second,t[v].first),t[v].second);
t[2*v+1].first=min(max(t[2*v+1].first,t[v].first),t[v].second);
t[2*v+1].second=min(max(t[2*v+1].second,t[v].first),t[v].second);
t[v].first=0;
t[v].second=1e5+10;
int mid=(l+r)/2;
if(a<=mid)
get(l,mid,2*v,a);
else
get(mid+1,r,2*v+1,a);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i=0;i<k;i++)
update(left[i],right[i],0,n-1,1,height[i],op[i]);
for(int i=0;i<n;i++)
finalHeight[i]=get(0,n-1,1,i);
return;
}
Compilation message (stderr)
wall.cpp: In function 'int get(int, int, int, int)':
wall.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |