# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
160681 |
2019-10-29T10:21:30 Z |
TAISA_ |
Wall (IOI14_wall) |
C++14 |
|
942 ms |
59424 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (1 << 30) - 1;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
struct Segtree {
int n;
vector<P> dat;
P ei = P(INF, -INF);
Segtree(int n_) {
n = 1;
while (n < n_) {
n <<= 1;
}
dat.resize(2 * n, ei);
}
inline void merge(P &p1, P p2) {
chmin(p1.first, p2.first);
chmin(p1.second, p2.first);
chmax(p1.second, p2.second);
}
inline void eval(int k) {
if (k < n) {
merge(dat[k << 1], dat[k]);
merge(dat[k << 1 | 1], dat[k]);
dat[k] = ei;
}
}
void upd(int a, int b, P x, int k, int l, int r) {
eval(k);
if (b <= l || r <= a) {
return;
}
if (a <= l && r <= b) {
merge(dat[k], x);
eval(k);
return;
}
upd(a, b, x, k << 1, l, (l + r) >> 1);
upd(a, b, x, k << 1 | 1, (l + r) >> 1, r);
}
inline void upd(int a, int b, P x) { return upd(a, b, x, 1, 0, n); }
int get(int k, int x) {
k += n;
P p = dat[k];
k >>= 1;
while (k > 0) {
merge(p, dat[k]);
k >>= 1;
}
chmin(x, p.first);
chmax(x, p.second);
return x;
}
void out() {
for (int i = 0; i < 2 * n; i++) {
cout << i << " " << dat[i].first << " " << dat[i].second << endl;
}
}
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[],
int finalHeight[]) {
Segtree seg(n);
for (int i = 0; i < k; i++) {
if (op[i] == 1) {
seg.upd(left[i], right[i] + 1, P(INF, height[i]));
} else {
seg.upd(left[i], right[i] + 1, P(height[i], -INF));
}
}
for (int i = 0; i < n; i++) {
finalHeight[i] = seg.get(i, 0);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
352 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
248 KB |
Output is correct |
4 |
Correct |
9 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
760 KB |
Output is correct |
6 |
Correct |
7 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
178 ms |
13904 KB |
Output is correct |
3 |
Correct |
228 ms |
8028 KB |
Output is correct |
4 |
Correct |
632 ms |
20216 KB |
Output is correct |
5 |
Correct |
380 ms |
20728 KB |
Output is correct |
6 |
Correct |
365 ms |
19252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
8 ms |
760 KB |
Output is correct |
5 |
Correct |
7 ms |
760 KB |
Output is correct |
6 |
Correct |
8 ms |
816 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
172 ms |
13944 KB |
Output is correct |
9 |
Correct |
225 ms |
7984 KB |
Output is correct |
10 |
Correct |
704 ms |
20252 KB |
Output is correct |
11 |
Correct |
378 ms |
20760 KB |
Output is correct |
12 |
Correct |
366 ms |
19212 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
177 ms |
13988 KB |
Output is correct |
15 |
Correct |
39 ms |
1912 KB |
Output is correct |
16 |
Correct |
667 ms |
20256 KB |
Output is correct |
17 |
Correct |
369 ms |
19676 KB |
Output is correct |
18 |
Correct |
364 ms |
19716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
760 KB |
Output is correct |
5 |
Correct |
8 ms |
760 KB |
Output is correct |
6 |
Correct |
8 ms |
760 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
177 ms |
13944 KB |
Output is correct |
9 |
Correct |
224 ms |
7980 KB |
Output is correct |
10 |
Correct |
632 ms |
20348 KB |
Output is correct |
11 |
Correct |
368 ms |
20756 KB |
Output is correct |
12 |
Correct |
382 ms |
19196 KB |
Output is correct |
13 |
Correct |
2 ms |
380 KB |
Output is correct |
14 |
Correct |
196 ms |
14040 KB |
Output is correct |
15 |
Correct |
37 ms |
1912 KB |
Output is correct |
16 |
Correct |
655 ms |
20220 KB |
Output is correct |
17 |
Correct |
359 ms |
19704 KB |
Output is correct |
18 |
Correct |
374 ms |
19704 KB |
Output is correct |
19 |
Correct |
920 ms |
59236 KB |
Output is correct |
20 |
Correct |
915 ms |
59268 KB |
Output is correct |
21 |
Correct |
941 ms |
59204 KB |
Output is correct |
22 |
Correct |
939 ms |
59380 KB |
Output is correct |
23 |
Correct |
921 ms |
59340 KB |
Output is correct |
24 |
Correct |
913 ms |
59376 KB |
Output is correct |
25 |
Correct |
907 ms |
59256 KB |
Output is correct |
26 |
Correct |
934 ms |
59368 KB |
Output is correct |
27 |
Correct |
942 ms |
59424 KB |
Output is correct |
28 |
Correct |
941 ms |
59352 KB |
Output is correct |
29 |
Correct |
908 ms |
59384 KB |
Output is correct |
30 |
Correct |
907 ms |
59296 KB |
Output is correct |