# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731161 |
2023-04-27T05:53:05 Z |
Desh03 |
Wall (IOI14_wall) |
C++17 |
|
502 ms |
20152 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct segtree {
vector<int> st, t, o;
int sz;
segtree(int n) {
sz = n;
while (__builtin_popcount(sz) ^ 1) sz++;
st.resize(sz << 1), o.resize(sz << 1, -1);
}
void change(int v, int val, int op) {
if (o[v] == -1 && v < sz) st[v] = val, o[v] = op;
else if (op == 1) {
if (st[v] <= val) {
st[v] = val;
o[v] = 1;
}
} else if (op == 2) {
if (st[v] >= val) {
st[v] = val;
o[v] = 2;
}
}
}
void push(int v) {
change(v << 1, st[v], o[v]);
change(v << 1 | 1, st[v], o[v]);
o[v] = -1;
}
void upd(int v, int l, int r, int ql, int qr, int op, int h) {
if (l > qr || r < ql) return;
if (l >= ql && r <= qr) {
change(v, h, op);
return;
}
if (o[v] != -1) push(v);
int m = l + r >> 1;
upd(v << 1, l, m, ql, qr, op, h);
upd(v << 1 | 1, m + 1, r, ql, qr, op, h);
}
void pushdown(int v) {
if (v >= sz) return;
if (o[v] != -1) push(v);
pushdown(v << 1);
pushdown(v << 1 | 1);
}
void upd(int l, int r, int op, int h) {
upd(1, 0, sz - 1, l, r, op, h);
}
int get(int i) {
return st[i + sz];
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int hieght[], int finalhieght[]) {
segtree st(n);
for (int i = 0; i < k; i++)
st.upd(left[i], right[i], op[i], hieght[i]);
st.pushdown(1);
for (int i = 0; i < n; i++) finalhieght[i] = st.get(i);
}
Compilation message
wall.cpp: In member function 'void segtree::upd(int, int, int, int, int, int, int)':
wall.cpp:39:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
39 | int m = l + r >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Incorrect |
2 ms |
304 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
133 ms |
13848 KB |
Output is correct |
3 |
Correct |
190 ms |
7840 KB |
Output is correct |
4 |
Incorrect |
502 ms |
20152 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
436 KB |
Output is correct |
3 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |