#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
struct Node {
int l, r;
Node operator+(const Node& n) const {
if (n.r < l) {
return {n.r, n.r};
} else if (r < n.l) {
return {n.l, n.l};
}
return {max(l, n.l), min(r, n.r)};
}
} ndef {0, int(1e9)};
struct ST {
int n;
vector<Node> v;
ST(int n) : n(n), v(4 * n, ndef) {}
void set(int o, int l, int r, int ind, const Node& x) {
if (l == r) {
v[o] = x;
} else {
int mid = (l + r) / 2, lc = o * 2, rc = lc + 1;
if (ind <= mid) {
set(lc, l, mid, ind, x);
} else {
set(rc, mid + 1, r, ind, x);
}
v[o] = v[lc] + v[rc];
}
}
void set(int ind, const Node& x) {
set(1, 0, n - 1, ind, x);
}
Node query_all() {
return v[1];
}
};
void buildWall(int n,
int q,
int op[],
int ql[],
int qr[],
int qx[],
int out[]) {
vector<pair<bool, int>> ops[n + 1];
for (int i = 0; i < q; i++) {
ops[ql[i]].emplace_back(true, i);
ops[qr[i] + 1].emplace_back(false, i);
}
ST st(q);
for (int i = 0; i < n; i++) {
for (auto& [add, j] : ops[i]) {
if (add) {
if (op[j] == 1) {
st.set(j, {qx[j], int(1e9)});
} else {
st.set(j, {0, qx[j]});
}
} else {
st.set(j, ndef);
}
}
out[i] = st.query_all().l;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
692 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
7 ms |
1084 KB |
Output is correct |
5 |
Correct |
5 ms |
1108 KB |
Output is correct |
6 |
Correct |
5 ms |
1012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
216 ms |
37648 KB |
Output is correct |
3 |
Correct |
181 ms |
19520 KB |
Output is correct |
4 |
Correct |
540 ms |
50080 KB |
Output is correct |
5 |
Correct |
290 ms |
48720 KB |
Output is correct |
6 |
Correct |
294 ms |
46648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
484 KB |
Output is correct |
4 |
Correct |
6 ms |
1108 KB |
Output is correct |
5 |
Correct |
5 ms |
1012 KB |
Output is correct |
6 |
Correct |
4 ms |
1108 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
219 ms |
37548 KB |
Output is correct |
9 |
Correct |
153 ms |
19512 KB |
Output is correct |
10 |
Correct |
522 ms |
50044 KB |
Output is correct |
11 |
Correct |
310 ms |
48744 KB |
Output is correct |
12 |
Correct |
277 ms |
46652 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
214 ms |
37624 KB |
Output is correct |
15 |
Correct |
28 ms |
3796 KB |
Output is correct |
16 |
Correct |
571 ms |
50028 KB |
Output is correct |
17 |
Correct |
322 ms |
47376 KB |
Output is correct |
18 |
Correct |
315 ms |
46724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
724 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
1108 KB |
Output is correct |
5 |
Correct |
4 ms |
1108 KB |
Output is correct |
6 |
Correct |
4 ms |
1080 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
208 ms |
37644 KB |
Output is correct |
9 |
Correct |
209 ms |
19584 KB |
Output is correct |
10 |
Correct |
513 ms |
49996 KB |
Output is correct |
11 |
Correct |
314 ms |
48900 KB |
Output is correct |
12 |
Correct |
275 ms |
46656 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
203 ms |
37648 KB |
Output is correct |
15 |
Correct |
28 ms |
3652 KB |
Output is correct |
16 |
Correct |
603 ms |
50012 KB |
Output is correct |
17 |
Correct |
332 ms |
47408 KB |
Output is correct |
18 |
Correct |
324 ms |
46768 KB |
Output is correct |
19 |
Correct |
587 ms |
113292 KB |
Output is correct |
20 |
Correct |
557 ms |
113328 KB |
Output is correct |
21 |
Correct |
556 ms |
113204 KB |
Output is correct |
22 |
Correct |
548 ms |
113240 KB |
Output is correct |
23 |
Correct |
586 ms |
113216 KB |
Output is correct |
24 |
Correct |
538 ms |
113200 KB |
Output is correct |
25 |
Correct |
553 ms |
113216 KB |
Output is correct |
26 |
Correct |
573 ms |
113260 KB |
Output is correct |
27 |
Correct |
639 ms |
113232 KB |
Output is correct |
28 |
Correct |
546 ms |
113168 KB |
Output is correct |
29 |
Correct |
544 ms |
113228 KB |
Output is correct |
30 |
Correct |
595 ms |
113228 KB |
Output is correct |