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 <bits/stdc++.h>
using namespace std;
struct LazySegmentTree {
};
void buildWall(int n, int k, int op[], int left[],int right[],int height[], int finalHeight[]) {
int MAX = 0;
for(int i = 0; i < k; i++) {
MAX = max(MAX,height[i]);
}
vector<int>l(n,0),r(n,MAX+1);
vector<array<int,3>>tmp1,tmp2;
for(int i = 0; i < k; i++) {
if(op[i] == 1) {
tmp1.push_back({height[i],1,i});
}
else {
tmp2.push_back({height[i],1,i});
}
}
while(true) {
bool f = false;
for(int i = 0; i < n; i++) {
if(l[i]+1 < r[i]) f = true;
}
if(!f) break;
vector<array<int,3>>q1 = tmp1,q2 = tmp2;
for(int i = 0; i < n; i++) {
if(l[i]+1 < r[i]) {
int mid = (l[i]+r[i])/2;
q1.push_back({mid,0,i});
q2.push_back({mid,0,i});
}
}
sort(q1.rbegin(),q1.rend());
sort(q2.begin(),q2.end());
vector<int>mx1(n),mx2(n);
vector<int>s1(n,-1),s2(n,-1);
{
for(int i = 0; i < q1.size(); i++) {
if(q1[i][1] == 1) {
int id = q1[i][2];
for(int j = left[id]; j <= right[id]; j++) {
s1[j] = max(s1[j],id);
}
}
else {
mx1[q1[i][2]] = s1[q1[i][2]];
}
}
}
{
for(int i = 0; i < q2.size(); i++) {
if(q2[i][1] == 1) {
int id = q2[i][2];
for(int j = left[id]; j <= right[id]; j++) {
s2[j] = max(s2[j],id);
}
}
else {
mx2[q2[i][2]] = s2[q2[i][2]];
}
}
}
for(int i = 0; i < n; i++) {
if(l[i]+1 < r[i]) {
int mid = (l[i]+r[i])/2;
if(mx2[i] < mx1[i]) {
l[i] = mid;
}
else {
r[i] = mid;
}
}
}
}
for(int i = 0; i < n; i++) {
finalHeight[i] = l[i];
}
}
Compilation message (stderr)
wall.cpp: In function 'void buildWall(int, int, int*, int*, int*, int*, int*)':
wall.cpp:41:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(int i = 0; i < q1.size(); i++) {
| ~~^~~~~~~~~~~
wall.cpp:54:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i = 0; i < q2.size(); i++) {
| ~~^~~~~~~~~~~
# | 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... |