이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 200
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf= 4e18;
const ld pai=acos(-1);
#include "wall.h"
int n,q;
vi MX[100009][2],MN[100009][2];
int mx[100009],mn[100009];
void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
n=N,q=k;
for(int i=0;i<n;i++)finalHeight[i]=0;
if(n<=1e4 && q<=5e3){
for(int i=0;i<q;i++){
int t=op[i];
int l=left[i];
int r=right[i];
int h=height[i];
for(int j=l;j<=r;j++){
if(t==1){
finalHeight[j]=max(finalHeight[j],h);
}
if(t==2){
finalHeight[j]=min(finalHeight[j],h);
}
}
}
return ;
}
for(int i=0;i<q;i++){
int t=op[i];
int l=left[i];
int r=right[i];
int h=height[i];
if(t==1){
MX[l][0].pb(h);
MX[r][1].pb(h);
}
if(t==2){
MN[l][0].pb(h);
MN[r][1].pb(h);
}
}
mset<int>s;
for(int i=0;i<n;i++)mn[i]=1e9;
for(int i=0;i<n;i++){
for(auto u:MX[i][0])s.ins(u);
if(s.size())mx[i]=*s.rbegin();
for(auto u:MX[i][1])s.era(s.find(u));
}
s.clear();
for(int i=0;i<n;i++){
for(auto u:MN[i][0])s.ins(u);
if(s.size())mn[i]=*s.begin();
for(auto u:MN[i][1])s.era(s.find(u));
}
for(int i=0;i<n;i++){
if(mn[i]<mx[i]){
finalHeight[i]=mn[i];
}
else{
finalHeight[i]=mx[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... |