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 <iostream>
#include <vector>
#include "wall.h"
#include <set>
using namespace std;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
/*if(n <= 10000 && k <= 5000){
vector<int> heightl (n, 0);
for(int update = 0; update < k; update++){
for(int setter = left[update]; setter <= right[update]; setter++){
if(op[update] == 1) heightl[setter] = max(heightl[setter], height[update]);
else heightl[setter] = min(heightl[setter], height[update]);
}
}
for(int finisher = 0; finisher < n; finisher++) finalHeight[finisher] = heightl[finisher];
}
else{*/
vector<vector<int>> adds (n);
vector<vector<int>> adde (n+1);
vector<vector<int>> subs (n);
vector<vector<int>> sube (n+1);
for(int update = 0; update < k; update++){
if(op[update] == 1){
adds[left[update]].push_back(height[update]);
adde[right[update]+1].push_back(height[update]);
}
else{
subs[left[update]].push_back(height[update]);
sube[right[update]+1].push_back(height[update]);
}
}
vector<int> mad (n, 0);
multiset<int, greater<>> b;
for(int madder = 0; madder < n; madder++){
for(int ins : adds[madder]) b.insert(ins);
for(int rm : adde[madder]) b.erase(rm);
mad[madder] = *(b.begin());
}
vector<int> msu (n, 0);
multiset<int> s;
for(int madder = 0; madder < n; madder++){
for(int ins : subs[madder]) s.insert(ins);
for(int rm : sube[madder]) s.erase(rm);
msu[madder] = *(s.begin());
}
for(int finisher = 0; finisher < n; finisher++) finalHeight[finisher] = min(mad[finisher], msu[finisher]);
//}
}
# | 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... |