# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164155 | kostia244 | Wall (IOI14_wall) | C++17 | 1135 ms | 28804 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>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int fh[]){
if(n <= 10000) {
for(int i = 0; i < k; i++) {
if(op[i]==1) {
for(int p = l[i]; p <= r[i]; p++)
if(fh[p]<h[i]) fh[p] = h[i];
} else {
for(int p = l[i]; p <= r[i]; p++)
if(fh[p]>h[i]) fh[p] = h[i];
}
}
return;
}
vector<pair<int, int>> o[2][2];
for(int i = 0; i < k; i++) {
o[op[i]-1][0].pb({l[i], h[i]});
o[op[i]-1][1].pb({r[i]+1, h[i]});
}
for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) sort(all(o[i][j]));
int xa, xb, ya, yb;
xa=xb=ya=yb=0;
multiset<int, greater<int>> x;
multiset<int> y;
for(int i = 0; i < n; i++) {
while(xa<o[0][0].size()&&o[0][0][xa].first==i) {
x.insert(o[0][0][xa].second);
xa++;
}
while(xb<o[0][1].size()&&o[0][1][xb].first==i) {
x.erase(x.find(o[0][1][xb].second));
xb++;
}
while(ya<o[1][0].size()&&o[1][0][ya].first==i) {
y.insert(o[1][0][ya].second);
ya++;
}
while(yb<o[1][1].size()&&o[1][1][yb].first==i) {
y.erase(y.find(o[1][1][yb].second));
yb++;
}
fh[i] = min(x.empty()?0:*x.begin(), y.empty()?INT_MAX:*y.begin());
}
return;
}
Compilation message (stderr)
# | 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... |