# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
122610 |
2019-06-28T18:51:05 Z |
brcode |
Wall (IOI14_wall) |
C++14 |
|
1034 ms |
186360 KB |
#include <iostream>
#include "wall.h"
using namespace std;
struct node{
int mn,mx;
};
const int MAXN = 4e6+5;
pair<int,int> lazy[4*MAXN];
int ans[MAXN];
int seg[4*MAXN];
void push(int curr,int l,int r){
if(lazy[curr].first == -1e9 && lazy[curr].second == 1e9){
return;
}
seg[curr] = max(seg[curr],lazy[curr].first);
seg[curr] = min(seg[curr],lazy[curr].second);
if(l!=r){
auto a = lazy[2*curr];
auto b = lazy[curr];
if(b.second<=a.first){
a = make_pair(b.second,b.second);
}else if(a.second<=b.first){
a = make_pair(b.first,b.first);
}else{
a.first = max(a.first,b.first);
a.second = min(a.second,b.second);
}
lazy[2*curr] = a;
a= lazy[2*curr+1];
b = lazy[curr];
if(b.second<=a.first){
a = make_pair(b.second,b.second);
}else if(b.first>=a.second){
a = make_pair(b.first,b.first);
}else{
a.first = max(a.first,b.first);
a.second = min(a.second,b.second);
}
lazy[2*curr+1] = a;
}
lazy[curr] = make_pair(-1e9,1e9);
}
void update(int curr,int l,int r,int tl,int tr,pair<int,int> p1){
push(curr,l,r);
if(l>tr||r<tl){
return;
}
if(l>=tl && r<=tr){
lazy[curr] = p1;
push(curr,l,r);
return;
}
int mid = (l+r)/2;
update(2*curr,l,mid,tl,tr,p1);
update(2*curr+1,mid+1,r,tl,tr,p1);
}
void solve(int curr,int l,int r){
push(curr,l,r);
if(l==r){
ans[l-1] = seg[curr];
return;
}
int mid = (l+r)/2;
solve(2*curr,l,mid);
solve(2*curr+1,mid+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[],int height[], int finalHeight[]){
for(int i=0;i<4*MAXN;i++){
lazy[i] = make_pair(-1e9,1e9);
}
for(int i=0;i<k;i++){
if(op[i] == 1){
update(1,1,n,left[i]+1,right[i]+1,make_pair(height[i],1e9));
}else{
update(1,1,n,left[i]+1,right[i]+1,make_pair(-1e9,height[i]));
}
}
solve(1,1,n);
for(int i=0;i<n;i++){
finalHeight[i] = ans[i];
// cout<<i<<" "<<ans[i]<<endl;
}
}
/*int main(){
int n,k;
cin>>n>>k;
int left[k+1];
int right[k+1];
int height[k+1];
int type[k+1];
int finalHeight[k+1];
for(int i=0;i<k;i++){
cin>>type[i]>>left[i]>>right[i]>>height[i];
}
buildWall(n,k,type,left,right,height,finalHeight);
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
125576 KB |
Output is correct |
2 |
Correct |
111 ms |
125688 KB |
Output is correct |
3 |
Correct |
105 ms |
125664 KB |
Output is correct |
4 |
Correct |
124 ms |
125944 KB |
Output is correct |
5 |
Correct |
111 ms |
125944 KB |
Output is correct |
6 |
Correct |
111 ms |
126040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
125688 KB |
Output is correct |
2 |
Correct |
277 ms |
139220 KB |
Output is correct |
3 |
Correct |
363 ms |
133240 KB |
Output is correct |
4 |
Correct |
905 ms |
145032 KB |
Output is correct |
5 |
Correct |
460 ms |
146156 KB |
Output is correct |
6 |
Correct |
448 ms |
144632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
125732 KB |
Output is correct |
2 |
Correct |
107 ms |
125648 KB |
Output is correct |
3 |
Correct |
114 ms |
125688 KB |
Output is correct |
4 |
Correct |
123 ms |
125944 KB |
Output is correct |
5 |
Correct |
111 ms |
125992 KB |
Output is correct |
6 |
Correct |
111 ms |
125944 KB |
Output is correct |
7 |
Correct |
105 ms |
125560 KB |
Output is correct |
8 |
Correct |
277 ms |
139256 KB |
Output is correct |
9 |
Correct |
367 ms |
133112 KB |
Output is correct |
10 |
Correct |
862 ms |
145016 KB |
Output is correct |
11 |
Correct |
457 ms |
146040 KB |
Output is correct |
12 |
Correct |
446 ms |
144504 KB |
Output is correct |
13 |
Correct |
104 ms |
125560 KB |
Output is correct |
14 |
Correct |
276 ms |
139256 KB |
Output is correct |
15 |
Correct |
153 ms |
127224 KB |
Output is correct |
16 |
Correct |
1034 ms |
145328 KB |
Output is correct |
17 |
Correct |
456 ms |
144692 KB |
Output is correct |
18 |
Correct |
471 ms |
144760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
115 ms |
125736 KB |
Output is correct |
2 |
Correct |
106 ms |
125688 KB |
Output is correct |
3 |
Correct |
130 ms |
125568 KB |
Output is correct |
4 |
Correct |
125 ms |
125944 KB |
Output is correct |
5 |
Correct |
109 ms |
125944 KB |
Output is correct |
6 |
Correct |
118 ms |
126044 KB |
Output is correct |
7 |
Correct |
104 ms |
125560 KB |
Output is correct |
8 |
Correct |
283 ms |
139228 KB |
Output is correct |
9 |
Correct |
361 ms |
133000 KB |
Output is correct |
10 |
Correct |
865 ms |
145144 KB |
Output is correct |
11 |
Correct |
457 ms |
146076 KB |
Output is correct |
12 |
Correct |
450 ms |
144580 KB |
Output is correct |
13 |
Correct |
103 ms |
125560 KB |
Output is correct |
14 |
Correct |
275 ms |
139228 KB |
Output is correct |
15 |
Correct |
152 ms |
127220 KB |
Output is correct |
16 |
Correct |
1022 ms |
145296 KB |
Output is correct |
17 |
Correct |
454 ms |
144636 KB |
Output is correct |
18 |
Correct |
454 ms |
144792 KB |
Output is correct |
19 |
Correct |
944 ms |
186232 KB |
Output is correct |
20 |
Correct |
936 ms |
183836 KB |
Output is correct |
21 |
Correct |
941 ms |
186232 KB |
Output is correct |
22 |
Correct |
960 ms |
183752 KB |
Output is correct |
23 |
Correct |
977 ms |
183716 KB |
Output is correct |
24 |
Correct |
941 ms |
183800 KB |
Output is correct |
25 |
Correct |
931 ms |
183672 KB |
Output is correct |
26 |
Correct |
945 ms |
186360 KB |
Output is correct |
27 |
Correct |
946 ms |
186156 KB |
Output is correct |
28 |
Correct |
931 ms |
183672 KB |
Output is correct |
29 |
Correct |
928 ms |
183772 KB |
Output is correct |
30 |
Correct |
930 ms |
183800 KB |
Output is correct |