# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
297428 |
2020-09-11T14:42:28 Z |
kevlee |
Wall (IOI14_wall) |
C++17 |
|
412 ms |
20856 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int seg[8000005], h, ans[2000005];
void update_add(int id, int l, int r, int ql, int qr) {
if (ql > r || qr < l) return;
if (ql <= l && r <= qr) {
seg[id] = max(seg[id], h);
return;
}
int mid = (l + r) >> 1;
update_add(id * 2, l, mid, ql, qr);
update_add(id * 2 + 1, mid + 1, r, ql, qr);
}
void update_remove(int id, int l, int r, int ql, int qr) {
if (ql > r || qr < l) return;
if (ql <= l && r <= qr) {
seg[id] = min(seg[id], h);
return;
}
int mid = (l + r) >> 1;
update_remove(id * 2, l, mid, ql, qr);
update_remove(id * 2 + 1, mid + 1, r, ql, qr);
}
void propagate_add(int id, int l, int r) {
if (l == r) {
return;
}
int mid = (l + r) >> 1;
seg[id * 2] = max(seg[id * 2], seg[id]);
seg[id * 2 + 1] = max(seg[id * 2 + 1], seg[id]);
propagate_add(id * 2, l, mid);
propagate_add(id * 2 + 1, mid + 1, r);
seg[id] = 1e9;
}
void propagate_remove(int id, int l, int r) {
if (l == r) {
ans[l] = seg[id];
return;
}
int mid = (l + r) >> 1;
seg[id * 2] = min(seg[id * 2], seg[id]);
seg[id * 2 + 1] = min(seg[id * 2 + 1], seg[id]);
propagate_remove(id * 2, l, mid);
propagate_remove(id * 2 + 1, mid + 1, r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
bool remove = false;
FOR(i, 0, k-1) {
left[i]++;
right[i]++;
h = height[i];
if (op[i] == 1) {
update_add(1, 1, n, left[i], right[i]);
} else {
if (!remove) {
remove = true;
propagate_add(1, 1, n);
}
update_remove(1, 1, n, left[i], right[i]);
}
}
propagate_remove(1, 1, n);
FOR(i, 0, n-1) finalHeight[i] = ans[i+1];
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
198 ms |
13944 KB |
Output is correct |
3 |
Correct |
154 ms |
7864 KB |
Output is correct |
4 |
Correct |
412 ms |
19804 KB |
Output is correct |
5 |
Correct |
298 ms |
20856 KB |
Output is correct |
6 |
Correct |
273 ms |
19320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |