# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
58005 |
2018-07-16T15:36:40 Z |
zetapi |
Wall (IOI14_wall) |
C++14 |
|
237 ms |
8276 KB |
//#include "wall.h"
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=5e6;
struct data
{
int Min;
int Max;
} Seg[MAX];
void Update(int low,int high,int node,int qlow,int qhigh,pii delta,int CurMin,int CurMax)
{
if(low>high or qlow>qhigh or qhigh<low or qlow>high)
return ;
if(Seg[node].Max>=CurMin and Seg[node].Min<=CurMax)
{
CurMin=max(CurMin,Seg[node].Min);
CurMax=min(CurMax,Seg[node].Max);
}
Seg[node].Min=CurMin;
Seg[node].Max=CurMax;
if(low>=qlow and high<=qhigh)
{
if(delta.second==1)
{
if(Seg[node].Min>delta.first)
return ;
Seg[node].Min=delta.first;
if(Seg[node].Max<Seg[node].Min)
Seg[node].Max=MAX;
}
else
{
if(Seg[node].Max<delta.first)
return ;
Seg[node].Max=delta.first;
Seg[node].Min=min(Seg[node].Min,Seg[node].Max);
}
return ;
}
int mid=(low+high)/2;
Update(low,mid,2*node,qlow,qhigh,delta,CurMin,CurMax);
Update(mid+1,high,2*node+1,qlow,qhigh,delta,CurMin,CurMax);
return ;
}
int query(int low,int high,int node,int X,int CurMin,int CurMax)
{
if(Seg[node].Max>=CurMin and Seg[node].Min<=CurMax)
{
CurMin=max(CurMin,Seg[node].Min);
CurMax=min(CurMax,Seg[node].Max);
}
if(low==high)
return CurMin;
int mid=(low+high)/2;
if(X>=low and X<=mid)
return query(low,mid,2*node,X,CurMin,CurMax);
else
return query(mid+1,high,2*node+1,X,CurMin,CurMax);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
int N=n,K=k;
for(int A=1;A<=3*N;A++)
{
Seg[A].Min=0;
Seg[A].Max=MAX;
}
for(int A=0;A<K;A++)
Update(1,N,1,left[A]+1,right[A]+1,mp(height[A],op[A]),0,MAX);
for(int A=0;A<N;A++)
finalHeight[A]=query(1,N,1,A+1,0,MAX);
return;
}
/*signed main()
{
ios_base::sync_with_stdio(false);
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Incorrect |
3 ms |
488 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
488 KB |
Output is correct |
2 |
Correct |
187 ms |
8276 KB |
Output is correct |
3 |
Incorrect |
237 ms |
8276 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8276 KB |
Output is correct |
2 |
Correct |
7 ms |
8276 KB |
Output is correct |
3 |
Incorrect |
4 ms |
8276 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8276 KB |
Output is correct |
2 |
Correct |
6 ms |
8276 KB |
Output is correct |
3 |
Incorrect |
4 ms |
8276 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |