# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
582308 |
2022-06-23T16:02:38 Z |
1ne |
Wall (IOI14_wall) |
C++14 |
|
3000 ms |
8124 KB |
#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
struct dataa{
long long x =0,type = 0,supp = 0,range = 0;
pair<long long,long long>lazy;
void add(long long left,long long right,pair<long long,long long> val){
if (type == 0){
x = val.second;
type = val.first;
}
else if (type == val.first){
if (val.first == 1){
if (supp!=type){
x = max(x,min(val.second,range));
}
else
x = max(x,val.second);
}
else{
if (supp!=type){
x = min(x,max(val.second,range));
}
else
x = min(x,val.second);
}
}
else if (supp == type){
range = val.second;
}
else{
if (val.first == 1){
range = max(range,val.second);
}
else{
range = min(range,val.second);
}
}
lazy = val;
supp|=val.first;
}
};
struct Segment_Tree{
vector<dataa>tree;
vector<int>index;
void init(long long n){
tree.resize(2*n - 1);
index.resize(n);
}
dataa combine(dataa left,dataa right){
dataa res;
res.type = (left.type | right.type);
res.supp = (left.supp | right.supp);
res.x = left.x + right.x;
if (left.type == 1){
res.range = max(left.range,right.range);
}
else res.range = min(left.range,right.range);
return res;
}
void push(long long node,long long left,long long right){
long long mid = (left + right)>>1;
long long z = node + ((mid - left + 1)<<1);
if (tree[node].lazy.first!=0){
tree[node + 1].add(left,mid,tree[node].lazy);
tree[z].add(mid + 1,right,tree[node].lazy);
tree[node].lazy.first = 0;
}
}
dataa query(long long node,long long left,long long right,long long qleft,long long qright){
if (qright<left|| qleft > right)return {0,0,0,0};
if (qleft<=left && qright>=right){
if (left == right){
index[left] = node;
}
return tree[node];
}
push(node,left,right);
long long mid = (left + right)>>1;
long long z = node + ((mid - left + 1)<<1);
return combine(query(node + 1,left,mid,qleft,qright),query(z,mid + 1,right,qleft,qright));
}
void update(long long node,long long left,long long right,long long uleft,long long uright,pair<long long,long long> v){
if (left > uright || right < uleft) return;
if (uleft <= left && right <=uright){
tree[node].add(left,right,v);
return;
}
push(node,left,right);
long long mid = (left + right)>>1;
long long z = node + ((mid - left + 1)<<1);
if (uleft<=mid){
update(node + 1,left,mid,uleft,uright,v);
}
if (uright > mid){
update(z,mid + 1,right,uleft,uright,v);
}
tree[node] = combine(tree[node + 1],tree[z]);
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
Segment_Tree st;
st.init(n);
function<void(int,int,int,int)> solve = [&](int l,int r,int o,int v){
if (l > r)return;
int temp = st.query(0,0,n-1,l,r).supp;
if (temp == o || temp == 0){
st.update(0,0,n-1,l,r,make_pair(o,v));
return;
}
else if (l == r){
st.update(0,0,n-1,l,r,make_pair(o,v));
}
else{
int mid = (l + r)>>1;
solve(l,mid,o,v);
solve(mid + 1,r,o,v);
}
};
for (int i = k - 1;i>=0;--i){
solve(left[i],right[i],op[i],height[i]);
}
for (int i = 0;i<n;++i){
solve(i,i,2,0);
}
for (int i = 0;i<n;++i){
st.query(0,0,n-1,i,i);
finalHeight[i] = st.tree[st.index[i]].x;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
260 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Incorrect |
88 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
142 ms |
8124 KB |
Output is correct |
3 |
Execution timed out |
3022 ms |
5396 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
82 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Incorrect |
122 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |