# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
138183 |
2019-07-29T14:22:50 Z |
junodeveloper |
Wall (IOI14_wall) |
C++14 |
|
1105 ms |
99472 KB |
#include "wall.h"
#include <algorithm>
using namespace std;
struct node {
int mx,mn;
} T[4*2000010];
void apply(int h,int mn,int mx) {
if(T[h].mx<mn) T[h].mx=T[h].mn=mn;
else if(mx<T[h].mn) T[h].mx=T[h].mn=mx;
else {
T[h].mn=max(T[h].mn,mn);
T[h].mx=min(T[h].mx,mx);
}
}
void update(int h,int tl,int tr,int l,int r,int mn,int mx) {
if(h>1)apply(h,T[h/2].mn,T[h/2].mx);
if(tr<l||r<tl)return;
if(l<=tl&&tr<=r) {
apply(h,mn,mx);
return;
}
int mid=(tl+tr)>>1;
update(h*2,tl,mid,l,r,mn,mx);
update(h*2+1,mid+1,tr,l,r,mn,mx);
T[h].mn=min(T[h*2].mn,T[h*2+1].mn);
T[h].mx=max(T[h*2].mx,T[h*2+1].mx);
}
int query(int h,int tl,int tr,int p){
if(h>1)apply(h,T[h/2].mn,T[h/2].mx);
if(tl==tr) return T[h].mn;
int mid=(tl+tr)>>1;
if(p<=mid) return query(h*2,tl,mid,p);
return query(h*2+1,mid+1,tr,p);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) {
int i,mn,mx;
for(i=0;i<=4*n;i++) T[i]={0,0};
for(i=0;i<k;i++) {
if(op[i]==1) mn=height[i],mx=1e9;
else mn=0,mx=height[i];
update(1,0,n-1,left[i],right[i],mn,mx);
}
for(i=0;i<n;i++) {
finalHeight[i]=query(1,0,n-1,i);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
888 KB |
Output is correct |
5 |
Correct |
8 ms |
888 KB |
Output is correct |
6 |
Correct |
8 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
174 ms |
8128 KB |
Output is correct |
3 |
Correct |
204 ms |
4288 KB |
Output is correct |
4 |
Correct |
591 ms |
21568 KB |
Output is correct |
5 |
Correct |
394 ms |
22520 KB |
Output is correct |
6 |
Correct |
373 ms |
20984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
10 ms |
888 KB |
Output is correct |
5 |
Correct |
8 ms |
888 KB |
Output is correct |
6 |
Correct |
8 ms |
912 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
174 ms |
14072 KB |
Output is correct |
9 |
Correct |
208 ms |
8056 KB |
Output is correct |
10 |
Correct |
641 ms |
21496 KB |
Output is correct |
11 |
Correct |
379 ms |
22572 KB |
Output is correct |
12 |
Correct |
376 ms |
20984 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
179 ms |
13916 KB |
Output is correct |
15 |
Correct |
40 ms |
2168 KB |
Output is correct |
16 |
Correct |
692 ms |
21744 KB |
Output is correct |
17 |
Correct |
384 ms |
21240 KB |
Output is correct |
18 |
Correct |
395 ms |
21240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
380 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
888 KB |
Output is correct |
5 |
Correct |
9 ms |
888 KB |
Output is correct |
6 |
Correct |
8 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
184 ms |
13944 KB |
Output is correct |
9 |
Correct |
206 ms |
8020 KB |
Output is correct |
10 |
Correct |
594 ms |
21496 KB |
Output is correct |
11 |
Correct |
380 ms |
22520 KB |
Output is correct |
12 |
Correct |
376 ms |
20984 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
180 ms |
13948 KB |
Output is correct |
15 |
Correct |
40 ms |
2040 KB |
Output is correct |
16 |
Correct |
703 ms |
21752 KB |
Output is correct |
17 |
Correct |
384 ms |
21176 KB |
Output is correct |
18 |
Correct |
386 ms |
21240 KB |
Output is correct |
19 |
Correct |
1095 ms |
99320 KB |
Output is correct |
20 |
Correct |
1056 ms |
96780 KB |
Output is correct |
21 |
Correct |
1076 ms |
99404 KB |
Output is correct |
22 |
Correct |
1056 ms |
97036 KB |
Output is correct |
23 |
Correct |
1059 ms |
96920 KB |
Output is correct |
24 |
Correct |
1052 ms |
96888 KB |
Output is correct |
25 |
Correct |
1054 ms |
96736 KB |
Output is correct |
26 |
Correct |
1097 ms |
99256 KB |
Output is correct |
27 |
Correct |
1105 ms |
99472 KB |
Output is correct |
28 |
Correct |
1097 ms |
96760 KB |
Output is correct |
29 |
Correct |
1058 ms |
96856 KB |
Output is correct |
30 |
Correct |
1058 ms |
96888 KB |
Output is correct |