이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
void buildWall(int n, int k, int t[], int l[], int r[], int h[], int finalHeight[]){
vi ans(n,0);
int m=sqrt(n);
vi b(m+2,0),c(m+2,inf);
REP(i,0,k){
int x=l[i]/m;
int y=r[i]/m;
REP(j,x+1,y){
if(t[i]==1){
b[j]=max(b[j],h[i]);
c[j]=max(c[j],h[i]);
}
else{
c[j]=min(c[j],h[i]);
b[j]=min(b[j],h[i]);
}
}
REP(j,x*m,min(n,x*m+m)){
ans[j]=min(ans[j],c[x]);
ans[j]=max(ans[j],b[x]);
}
b[x]=0;c[x]=inf;
REP(j,y*m,min(n,y*m+m)){
ans[j]=min(ans[j],c[y]);
ans[j]=max(ans[j],b[y]);
}
b[y]=0;c[y]=inf;
REP(j,l[i],min(min(n,x*m+m),r[i]+1)){
if(t[i]==1)ans[j]=max(ans[j],h[i]);
else ans[j]=min(ans[j],h[i]);
}
REP(j,max(l[i],y*m),r[i]+1){
if(t[i]==1)ans[j]=max(ans[j],h[i]);
else ans[j]=min(ans[j],h[i]);
}
}
REP(j,0,n){
ans[j]=min(ans[j],c[j/m]);
ans[j]=max(ans[j],b[j/m]);
}
REP(i,0,n)finalHeight[i]=ans[i];
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |