# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
164451 |
2019-11-20T17:07:32 Z |
kostia244 |
Wall (IOI14_wall) |
C++17 |
|
3000 ms |
118008 KB |
#include "wall.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
struct node {
int mn = 2e9, mx = 0, ord = 1;
void push(int x, int a) {
if (a == 1) { //mn
ord = 1;
mn = min(mn, x);
mx = min(mx, mn);
} else {
ord = 0;
mx = max(mx, x);
mn = max(mn, mx);
}
}
int eval() {
if (ord == 0) {
if(mn == 2e9) mn = 0;
return max(mn, mx);
}
return min(mn, mx);
}
};
node merge(node a, node b) {
if (b.ord == 1) {
a.push(b.mx, 0);
a.push(b.mn, 1);
} else {
a.push(b.mn, 1);
a.push(b.mx, 0);
}
return a;
}
vector<node> tree;
void push(int v, int l, int r) {
if(l==r) return;
tree[v<<1] = merge(tree[v<<1], tree[v]);
tree[v<<1|1] = merge(tree[v<<1|1], tree[v]);
tree[v] = node();
}
int get(int v, int l, int r, int i) {
push(v, l, r);
if (l > i || r < i)
return 0;
if (l == r)
return tree[v].eval();
int mid = (l + r) >> 1;
return get(v << 1, l, mid, i) + get(v << 1 | 1, mid + 1, r, i);
}
void upd(int v, int l, int r, int ql, int qr, int x, int a) {
push(v, l, r);
if (r < ql || l > qr)
return;
if (ql <= l && r <= qr) {
// cout << l << " " << r << " " << tree[v].eval() << "\n";
tree[v].push(x, a);
// cout << l << " " << r << " " << x << " " << a << " " << tree[v].ord << "\n";
push(v, l, r);
return;
}
int mid = (l + r) >> 1;
upd(v << 1, l, mid, ql, qr, x, a);
upd(v << 1 | 1, mid + 1, r, ql, qr, x, a);
}
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int fh[]) {
tree.resize(4*n + 100);
for(int i = 0; i < k; i++) {
upd(1, 0, n-1, l[i], r[i], h[i], (op[i]-1));
// cout <<"======\n";
}
for(int i = 0; i < n; i++)
fh[i] = get(1, 0, n-1, i);
return;
}
# |
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 |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
20 ms |
1144 KB |
Output is correct |
5 |
Correct |
18 ms |
1020 KB |
Output is correct |
6 |
Correct |
18 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
171 ms |
14040 KB |
Output is correct |
3 |
Correct |
437 ms |
8352 KB |
Output is correct |
4 |
Correct |
1343 ms |
23092 KB |
Output is correct |
5 |
Correct |
785 ms |
24256 KB |
Output is correct |
6 |
Correct |
767 ms |
22624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
19 ms |
1016 KB |
Output is correct |
5 |
Correct |
19 ms |
1020 KB |
Output is correct |
6 |
Correct |
18 ms |
1016 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
173 ms |
13944 KB |
Output is correct |
9 |
Correct |
439 ms |
8312 KB |
Output is correct |
10 |
Correct |
1332 ms |
23032 KB |
Output is correct |
11 |
Correct |
773 ms |
24268 KB |
Output is correct |
12 |
Correct |
767 ms |
22656 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
174 ms |
13944 KB |
Output is correct |
15 |
Correct |
79 ms |
2300 KB |
Output is correct |
16 |
Correct |
1347 ms |
23388 KB |
Output is correct |
17 |
Correct |
794 ms |
22824 KB |
Output is correct |
18 |
Correct |
774 ms |
22888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
504 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
19 ms |
1144 KB |
Output is correct |
5 |
Correct |
19 ms |
1016 KB |
Output is correct |
6 |
Correct |
18 ms |
1148 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
173 ms |
13916 KB |
Output is correct |
9 |
Correct |
479 ms |
8540 KB |
Output is correct |
10 |
Correct |
1337 ms |
23032 KB |
Output is correct |
11 |
Correct |
815 ms |
24184 KB |
Output is correct |
12 |
Correct |
768 ms |
22620 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
173 ms |
14044 KB |
Output is correct |
15 |
Correct |
91 ms |
2400 KB |
Output is correct |
16 |
Correct |
1338 ms |
23396 KB |
Output is correct |
17 |
Correct |
771 ms |
22948 KB |
Output is correct |
18 |
Correct |
770 ms |
22828 KB |
Output is correct |
19 |
Execution timed out |
3064 ms |
118008 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |