This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wall.h"
#include <bits/stdc++.h>
#define N 100005
using namespace std;
vector<int> st[N];
vector<int> nd[N];
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(int i = 0;i<n;i++){
finalHeight[i] = 0;
}
if(n <= 10000 && k <= 5000){
for(int i = 0;i<k;i++){
for(int j = left[i];j<=right[i];j++){
if(op[i] == 1){
finalHeight[j] = max(finalHeight[j],height[i]);
}
else{
finalHeight[j] = min(finalHeight[j],height[i]);
}
}
}
}
else{
multiset<int> maxs = {0};
multiset<int> mins = {(int)1e9};
for(int i = 0;i<k;i++){
st[left[i]].push_back(i);
nd[right[i] + 1].push_back(i);
}
for(int i = 0;i<n;i++){
for(auto u:st[i]){
if(op[u] == 1){
maxs.insert(height[u]);
}
else{
mins.insert(height[u]);
}
}
for(auto u:nd[i]){
if(op[u] == 1){
maxs.erase(maxs.find(height[u]));
}
else{
mins.erase(mins.find(height[u]));
}
}
finalHeight[i] = min(*maxs.rbegin(),*mins.begin());
}
}
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... |