# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
244014 |
2020-07-02T13:05:06 Z |
tleontest1 |
Wall (IOI14_wall) |
C++14 |
|
2978 ms |
28920 KB |
#include "wall.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const int inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 2000005;
const lo mod = 1000000007;
int flag,t,m,tree[li*4],lazy[li*4],tree1[li*4],lazy1[li*4],tree2[li*4],lazy2[li*4];
int cev;
inline void push1(int node,int start,int end){
if(lazy1[node]==inf)return ;
tree1[node]=min(tree1[node],lazy1[node]);
if(start!=end){
lazy1[node*2]=min(lazy1[node*2],lazy1[node]);
lazy1[node*2+1]=min(lazy1[node*2+1],lazy1[node]);
}
lazy1[node]=inf;
}
inline void update1(int node,int start,int end,int l,int r,int val){
push1(node,start,end);
if(start>end || start>r || end<l)return ;
if(start>=l && end<=r){
lazy1[node]=min(lazy1[node],val);
push1(node,start,end);
return ;
}
update1(node*2,start,mid,l,r,val);
update1(node*2+1,mid+1,end,l,r,val);
tree1[node]=min(tree1[node*2],tree1[node*2+1]);
}
inline int query1(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return inf;
push1(node,start,end);
if(start>=l && end<=r)return tree1[node];
return min(query1(node*2,start,mid,l,r),query1(node*2+1,mid+1,end,l,r));
}
inline void push(int node,int start,int end){
if(lazy[node]==0)return ;
tree[node]=max(tree[node],lazy[node]);
if(start!=end){
lazy[node*2]=max(lazy[node*2],lazy[node]);
lazy[node*2+1]=max(lazy[node*2+1],lazy[node]);
}
lazy[node]=0;
}
inline void update(int node,int start,int end,int l,int r,int val){
push(node,start,end);
if(start>end || start>r || end<l)return ;
if(start>=l && end<=r && min(val,query1(1,1,m,start,start))==min(val,query1(1,1,m,end,end))){
//~ cout<<query1(1,1,m,start,start)<<" : : "<<query1(1,1,m,end,end)<<" : : "<<start<<" ; : "<<end<<endl;;
lazy[node]=max(lazy[node],min(val,query1(1,1,m,start,start)));
push(node,start,end);
return ;
}
update(node*2,start,mid,l,r,val);
update(node*2+1,mid+1,end,l,r,val);
tree[node]=max(tree[node*2],tree[node*2+1]);
}
inline int query(int node,int start,int end,int l,int r){
if(start>end || start>r || end<l)return 0;
push(node,start,end);
if(start>=l && end<=r)return tree[node];
return max(query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r));
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
m=n;
for(int i=1;i<=4*n;i++){
tree1[i]=inf;
lazy1[i]=inf;
tree[i]=-1;
lazy[i]=-1;
tree2[i]=-1;
lazy2[i]=-1;
}
//~ int mn=inf;
for(int i=k-1;i>=0;i--){
//~ cout<<height[i]<<endl;
if(op[i]==2){
update1(1,1,n,left[i]+1,right[i]+1,height[i]);
continue;
}
//~ cout<<"**\n";
update(1,1,n,left[i]+1,right[i]+1,height[i]);
//~ if(op[i]==2)update1(1,1,n,left[i]+1,right[i]+1,height[i]);
//~ update2(1,1,n,left[i]+1,right[i]+1,i);
}
FOR{
//~ cout<<"**"<<query1(1,1,n,i,i)<<"**"<<endl;
//~ cout<<"()"<<query(1,1,n,i,i)<<"()"<<endl;
//~ if(query2(1,1,n,i,i)==-1){continue;}
//~ if(op[query2(1,1,n,i,i)]==1){
finalHeight[i-1]=max(query(1,1,n,i,i),0);
//~ }
//~ else{
//~ finalHeight[i-1]=min((query(1,1,n,i,i)==-1?inf:query(1,1,n,i,i)),query1(1,1,n,i,i));
//~ }
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
384 KB |
Output is correct |
4 |
Correct |
42 ms |
1536 KB |
Output is correct |
5 |
Correct |
30 ms |
1536 KB |
Output is correct |
6 |
Correct |
22 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
179 ms |
8696 KB |
Output is correct |
3 |
Correct |
2904 ms |
5880 KB |
Output is correct |
4 |
Correct |
1287 ms |
27896 KB |
Output is correct |
5 |
Incorrect |
920 ms |
28920 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
10 ms |
512 KB |
Output is correct |
4 |
Correct |
42 ms |
1664 KB |
Output is correct |
5 |
Correct |
21 ms |
1536 KB |
Output is correct |
6 |
Correct |
22 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
176 ms |
8572 KB |
Output is correct |
9 |
Correct |
2978 ms |
5880 KB |
Output is correct |
10 |
Correct |
1395 ms |
27780 KB |
Output is correct |
11 |
Incorrect |
920 ms |
28920 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
9 ms |
512 KB |
Output is correct |
4 |
Correct |
44 ms |
1656 KB |
Output is correct |
5 |
Correct |
22 ms |
1536 KB |
Output is correct |
6 |
Correct |
23 ms |
1536 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
186 ms |
8544 KB |
Output is correct |
9 |
Correct |
2975 ms |
5880 KB |
Output is correct |
10 |
Correct |
1336 ms |
27808 KB |
Output is correct |
11 |
Incorrect |
875 ms |
28920 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |