# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68365 |
2018-08-16T20:12:25 Z |
MKopchev |
Wall (IOI14_wall) |
C++14 |
|
960 ms |
211720 KB |
#include<bits/stdc++.h>
#include "wall.h"
using namespace std;
const int nmax=1<<21,inf=1e9;
struct vert
{
int small,big,red/*forced reduce*/,add/*forced add*/;
//red>=add
};
vert tree[2*nmax+42];
void upd(int &node,int &_node)
{
/*
tree[_node].add=max(tree[_node].add,tree[node].add);
tree[_node].red=min(tree[_node].red,tree[node].red);
if(tree[_node].add>tree[_node].red)
{
tree[_node].add=tree[node].add;
tree[_node].red=tree[node].red;
}
*/
tree[_node].add=min(tree[_node].add,tree[node].red);
tree[_node].add=max(tree[_node].add,tree[node].add);
tree[_node].red=min(tree[_node].red,tree[node].red);
tree[_node].red=max(tree[_node].red,tree[node].add);
assert(tree[_node].add<=tree[_node].red);
}
int _;
void update_node(int &node)
{
if(tree[node].red==inf&&tree[node].add==0)return;
_=node*2;
upd(node,_);
_++;
upd(node,_);
tree[node].red=inf;
tree[node].add=0;
}
void update_add(int node,int l,int r,int lq,int rq,int h)
{
if(l==lq&&r==rq)
{
if(tree[node].add>=h)return;
if(tree[node].add<=h&&h<=tree[node].red)
{
tree[node].add=h;
tree[node].small=h;
return;
}
//tree[node].add<h
tree[node].add=h;
tree[node].red=h;
tree[node].small=h;
tree[node].big=h;
return;
}
update_node(node);
int av=(l+r)/2;
if(lq<=av)update_add(node*2,l,av,lq,min(av,rq),h);
if(av<rq)update_add(node*2+1,av+1,r,max(av+1,lq),rq,h);
tree[node].small=min(tree[node*2].small,tree[node*2+1].small);
tree[node].big=min(tree[node*2].big,tree[node*2+1].big);
}
void update_reduce(int node,int l,int r,int lq,int rq,int h)
{
if(l==lq&&r==rq)
{
if(tree[node].red<=h)return;
if(tree[node].red>=h&&h>=tree[node].add)
{
tree[node].red=h;
tree[node].big=h;
return;
}
//tree[node].red>h
tree[node].add=h;
tree[node].red=h;
tree[node].small=h;
tree[node].big=h;
return;
}
update_node(node);
int av=(l+r)/2;
if(lq<=av)update_reduce(node*2,l,av,lq,min(av,rq),h);
if(av<rq)update_reduce(node*2+1,av+1,r,max(av+1,lq),rq,h);
tree[node].small=min(tree[node*2].small,tree[node*2+1].small);
tree[node].big=min(tree[node*2].big,tree[node*2+1].big);
}
int cop[nmax];
void move_down(int node,int l,int r)
{
if(l==r)
{
cop[l]=tree[node].add;
return;
}
update_node(node);
int av=(l+r)/2;
move_down(node*2,l,av);
move_down(node*2+1,av+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[])
{
for(int i=1;i<2*nmax+42;i++)
tree[i].red=inf;
for(int i=0;i<k;i++)
{
if(op[i]==1)update_add(1,0,n-1,left[i],right[i],height[i]);
else update_reduce(1,0,n-1,left[i],right[i],height[i]);
/*
for(int j=1;j<=4*n;j++)
cout<<tree[j].small<<" "<<tree[j].big<<" "<<tree[j].red<<" "<<tree[j].add<<endl;
*/
}
move_down(1,0,n-1);
for(int j=0;j<n;j++)
finalHeight[j]=cop[j];
}
/*
const int n=10,k=6;
int op[k]={1,2,2,1,1,2};
int lef[k]={1,4,3,0,2,6};
int righ[k]={8,9,6,5,2,7};
int height[k]={4,1,5,3,5,0};
int fin[n];
int main()
{
buildWall(n,k,op,lef,righ,height,fin);
for(int i=0;i<n;i++)cout<<fin[i]<<" ";cout<<endl;
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
66040 KB |
Output is correct |
2 |
Correct |
48 ms |
66156 KB |
Output is correct |
3 |
Correct |
47 ms |
66156 KB |
Output is correct |
4 |
Correct |
56 ms |
66448 KB |
Output is correct |
5 |
Correct |
56 ms |
66564 KB |
Output is correct |
6 |
Correct |
55 ms |
66856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
66856 KB |
Output is correct |
2 |
Correct |
245 ms |
80360 KB |
Output is correct |
3 |
Correct |
340 ms |
80360 KB |
Output is correct |
4 |
Correct |
959 ms |
94704 KB |
Output is correct |
5 |
Correct |
395 ms |
105312 KB |
Output is correct |
6 |
Correct |
393 ms |
106328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
106328 KB |
Output is correct |
2 |
Correct |
51 ms |
106328 KB |
Output is correct |
3 |
Correct |
51 ms |
106328 KB |
Output is correct |
4 |
Correct |
58 ms |
106328 KB |
Output is correct |
5 |
Correct |
58 ms |
106328 KB |
Output is correct |
6 |
Correct |
52 ms |
106328 KB |
Output is correct |
7 |
Correct |
45 ms |
106328 KB |
Output is correct |
8 |
Correct |
209 ms |
106328 KB |
Output is correct |
9 |
Correct |
305 ms |
106328 KB |
Output is correct |
10 |
Correct |
837 ms |
106328 KB |
Output is correct |
11 |
Correct |
365 ms |
106328 KB |
Output is correct |
12 |
Correct |
397 ms |
106328 KB |
Output is correct |
13 |
Correct |
50 ms |
106328 KB |
Output is correct |
14 |
Correct |
233 ms |
106328 KB |
Output is correct |
15 |
Correct |
94 ms |
106328 KB |
Output is correct |
16 |
Correct |
960 ms |
106328 KB |
Output is correct |
17 |
Correct |
416 ms |
106328 KB |
Output is correct |
18 |
Correct |
402 ms |
106328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
106328 KB |
Output is correct |
2 |
Correct |
47 ms |
106328 KB |
Output is correct |
3 |
Correct |
46 ms |
106328 KB |
Output is correct |
4 |
Correct |
57 ms |
106328 KB |
Output is correct |
5 |
Correct |
53 ms |
106328 KB |
Output is correct |
6 |
Correct |
56 ms |
106328 KB |
Output is correct |
7 |
Correct |
46 ms |
106328 KB |
Output is correct |
8 |
Correct |
209 ms |
106328 KB |
Output is correct |
9 |
Correct |
350 ms |
106328 KB |
Output is correct |
10 |
Correct |
872 ms |
106328 KB |
Output is correct |
11 |
Correct |
390 ms |
106352 KB |
Output is correct |
12 |
Correct |
367 ms |
106352 KB |
Output is correct |
13 |
Correct |
46 ms |
106352 KB |
Output is correct |
14 |
Correct |
237 ms |
106352 KB |
Output is correct |
15 |
Correct |
97 ms |
106352 KB |
Output is correct |
16 |
Correct |
951 ms |
106352 KB |
Output is correct |
17 |
Correct |
411 ms |
106352 KB |
Output is correct |
18 |
Correct |
391 ms |
106352 KB |
Output is correct |
19 |
Correct |
806 ms |
130432 KB |
Output is correct |
20 |
Correct |
818 ms |
138464 KB |
Output is correct |
21 |
Correct |
825 ms |
151276 KB |
Output is correct |
22 |
Correct |
828 ms |
151276 KB |
Output is correct |
23 |
Correct |
816 ms |
151276 KB |
Output is correct |
24 |
Correct |
821 ms |
151276 KB |
Output is correct |
25 |
Correct |
785 ms |
160084 KB |
Output is correct |
26 |
Correct |
785 ms |
173024 KB |
Output is correct |
27 |
Correct |
809 ms |
183204 KB |
Output is correct |
28 |
Correct |
830 ms |
190708 KB |
Output is correct |
29 |
Correct |
822 ms |
201284 KB |
Output is correct |
30 |
Correct |
815 ms |
211720 KB |
Output is correct |