# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
1082966 | | n1k | 벽 (IOI14_wall) | C++17 | | 3079 ms | 39844 KiB |
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>
using namespace std;
using ll = long long;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
vector<array<ll, 3>> v;
for(int i=0; i<k; i++){
v.push_back({left[i], i, 0});
v.push_back({right[i]+1, i, 1});
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
vector<ll> hu(k, -1), ho(k, -1);
for(int i=0; i<n; i++){
while(v.back()[0]<=i){
auto [b, id, tp]=v.back();
v.pop_back();
if(tp==0){
if(op[id]==1){
hu[id]=height[id];
}else{
ho[id]=height[id];
}
}else{
if(op[id]==1){
hu[id]=-1;
}else{
ho[id]=-1;
}
}
}
ll o = 1e18, u = -1;
bool bd = 1;
for(int j=k-1; j>=0; j--){
if(hu[j]!=-1){
u = max(u, hu[j]);
}if(ho[j]!=-1){
o = min(o, ho[j]);
}
// >= ?
if(u>o){
if(u==hu[j]){
finalHeight[i]=o;
bd=0;
break;
}else if(o==ho[j]){
finalHeight[i]=u;
bd=0;
break;
}else{
}
}
}
if(bd){
finalHeight[i]=max(0ll, u);
}
}
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... |