# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
289324 |
2020-09-02T14:43:32 Z |
BeanZ |
Wall (IOI14_wall) |
C++14 |
|
1 ms |
384 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
#define ll int
#define endl '\n'
const int N = 2e6 + 5;
ll stmin[N * 4], stmax[N * 4];
ll lazymin[N * 4], lazymax[N * 4];
ll res[N];
void down(ll k){
stmax[k << 1] = max(stmax[k << 1], lazymax[k]);
stmax[k << 1] = min(stmax[k << 1], lazymin[k]);
stmin[k << 1] = min(stmin[k << 1], lazymin[k]);
stmin[k << 1] = max(stmin[k << 1], lazymax[k]);
stmax[k << 1 | 1] = max(stmax[k << 1 | 1], lazymax[k]);
stmax[k << 1 | 1] = min(stmax[k << 1 | 1], lazymin[k]);
stmin[k << 1 | 1] = min(stmin[k << 1 | 1], lazymin[k]);
stmin[k << 1 | 1] = max(stmin[k << 1 | 1], lazymax[k]);
lazymax[k << 1 | 1] = max(lazymax[k << 1 | 1], lazymax[k]);
lazymin[k << 1 | 1] = min(lazymin[k << 1 | 1], lazymin[k]);
lazymin[k << 1 | 1] = max(lazymin[k << 1 | 1], lazymax[k]);
lazymax[k << 1 | 1] = min(lazymax[k << 1 | 1], lazymin[k]);
lazymax[k << 1] = max(lazymax[k << 1], lazymax[k]);
lazymin[k << 1] = min(lazymin[k << 1], lazymin[k]);
lazymin[k << 1] = max(lazymin[k << 1], lazymax[k]);
lazymax[k << 1] = min(lazymax[k << 1], lazymin[k]);
lazymax[k] = -1e9;
lazymin[k] = 1e9;
}
void upd(ll type, ll k, ll l, ll r, ll x, ll y, ll h){
if (x > r || y < l) return;
if (l != r) down(k);
if (x <= l && y >= r){
if (type == 1){
stmin[k] = max(stmin[k], h);
lazymin[k] = max(lazymin[k], h);
lazymax[k] = max(lazymax[k], h);
stmax[k] = max(stmax[k], h);
} else {
stmax[k] = min(stmax[k], h);
stmin[k] = min(stmin[k], h);
lazymax[k] = min(lazymax[k], h);
lazymin[k] = min(lazymin[k], h);
}
return;
}
ll mid = (l + r) >> 1;
upd(type, k << 1, l, mid, x, y, h);
upd(type, k << 1 | 1, mid + 1, r, x, y, h);
}
void get(ll k, ll l, ll r){
if (l != r) down(k);
if (l == r){
res[l] = stmax[k];
return;
}
ll mid = (l + r) >> 1;
get(k << 1, l, mid);
get(k << 1 | 1, mid + 1, r);
}
void buildWall(ll n, ll k, ll op[], ll left[], ll right[], ll height[], ll finalHeight[]){
for (int i = 1; i <= k; i++){
upd(op[i - 1], 1, 1, n, left[i - 1], right[i - 1], height[i - 1]);
}
get(1, 1, n);
for (int i = 1; i <= n; i++) finalHeight[i - 1] = res[i];
}
/*
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("time.in", "r")){
freopen("time.in", "r", stdin);
freopen("time.out", "w", stdout);
}
}
/*
*/
Compilation message
wall.cpp:83:1: warning: "/*" within comment [-Wcomment]
83 | /*
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |