#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;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
9720 KB |
Output is correct |
2 |
Incorrect |
14 ms |
9976 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
9724 KB |
Output is correct |
2 |
Correct |
813 ms |
39444 KB |
Output is correct |
3 |
Correct |
288 ms |
20984 KB |
Output is correct |
4 |
Correct |
1092 ms |
40188 KB |
Output is correct |
5 |
Correct |
330 ms |
28264 KB |
Output is correct |
6 |
Correct |
295 ms |
28068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
9720 KB |
Output is correct |
2 |
Incorrect |
16 ms |
9976 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
9720 KB |
Output is correct |
2 |
Incorrect |
14 ms |
9976 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |