#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
/*
ioi2014 day1 prob2 wall
*/
#include<wall.h>
void buildWall(int n,int k,int op[],int left[],int right[],int height[],int finalHeight[]){
static int ad[1<<22]={0};
static int re[1<<22]={0};
//当然のようにセグメントツリーを行う
//seg木は番兵のため1~nで行う ごめんね
for(int h=0;h<k;h++){
int hi=left[h]+1;
int mg=right[h]+1;
int ta=height[h];
int biL=1;
for(int j=20;j>=0;j--){
maxeq(ad[biL+biL],ad[biL]);
maxeq(ad[biL+biL+1],ad[biL]);
maxeq(re[biL+biL],ad[biL]);
maxeq(re[biL+biL+1],ad[biL]);
mineq(re[biL+biL],re[biL]);
mineq(re[biL+biL+1],re[biL]);
mineq(ad[biL+biL],re[biL]);
mineq(ad[biL+biL+1],re[biL]);
ad[biL]=0;
re[biL]=mod;
biL*=2;
if((hi-1)&(1<<j)){biL++;}
}
int biR=1;
for(int j=20;j>=0;j--){
maxeq(ad[biR+biR],ad[biR]);
maxeq(ad[biR+biR+1],ad[biR]);
maxeq(re[biR+biR],ad[biR]);
maxeq(re[biR+biR+1],ad[biR]);
mineq(re[biR+biR],re[biR]);
mineq(re[biR+biR+1],re[biR]);
mineq(ad[biR+biR],re[biR]);
mineq(ad[biR+biR+1],re[biR]);
ad[biR]=0;
re[biR]=mod;
biR*=2;
if((mg+1)&(1<<j)){biR++;}
}
cerr<<biL-(1<<21)<<" "<<biR-(1<<21)<<endl;
if(op[h]==1){//add
while(biL+1<biR){
if(biL%2==0){maxeq(ad[biL+1],ta);maxeq(re[biL+1],ta);}
if(biR%2==1){maxeq(ad[biR-1],ta);maxeq(re[biR-1],ta);}
biL/=2;biR/=2;
}
}else{//rem
while(biL+1<biR){
if(biL%2==0){mineq(re[biL+1],ta);mineq(ad[biL+1],ta);}
if(biR%2==1){mineq(re[biR-1],ta);mineq(ad[biR-1],ta);}
biL/=2;biR/=2;
}
}
}
//最後にセグ木の伝搬をする
for(int i=1;i<(1<<21);i++){
maxeq(ad[i+i],ad[i]);
maxeq(ad[i+i+1],ad[i]);
maxeq(re[i+i],ad[i]);
maxeq(re[i+i+1],ad[i]);
mineq(re[i+i],re[i]);
mineq(re[i+i+1],re[i]);
mineq(ad[i+i],re[i]);
mineq(ad[i+i+1],re[i]);
}
for(int i=0;i<n;i++){finalHeight[i]=ad[i+1+(1<<21)];}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |