# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
488725 |
2021-11-20T07:57:04 Z |
grt |
Wall (IOI14_wall) |
C++17 |
|
600 ms |
68664 KB |
#include <bits/stdc++.h>
#include <wall.h>
#define PB push_back
#define ST first
#define ND second
//#pragma GCC optimize ("O3")
//#pragma GCC target("tune=native")
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
const int INF = 2e9 + 10;
int n, k;
struct Node {
int h, H;
void eval(Node &u) {
h = max(h, u.h);
if(h > H) H = h;
H = min(H, u.H);
if(h > H) h = H;
}
};
Node T[(1 << 22)];
void prop(int x) {
T[2*x].eval(T[x]);
T[2*x+1].eval(T[x]);
T[x] = {-INF, INF};
}
void init(int l, int r, int v) {
T[v].h = -INF; T[v].H = INF;
if(l == r) return;
int mid = (l + r)/2;
init(l,mid,v*2);
init(mid+1,r,v*2+1);
}
void tree(int l, int r, int v) {
cout << l << " " << r << ": " << T[v].h << " " << T[v].H << "\n";
if(l==r) return;
tree(l,(l+r)/2,v*2);
tree((l+r)/2+1,r,v*2+1);
}
void upd(int a, int b, int l, int r, int v, Node u) {
if(a <= l && r <= b) {
T[v].eval(u);
return;
}
prop(v);
int mid = (l + r) / 2;
if(a <= mid) upd(a,b,l,mid,v*2,u);
if(mid < b) upd(a,b,mid+1,r,v*2+1,u);
}
int res[2'000'000 + 10];
void rec(int l, int r, int v) {
if(l == r) {
res[l] = min(max(T[v].h, 0), T[v].H);
return;
}
prop(v);
int mid = (l+r)/2;
rec(l,mid,v*2);
rec(mid+1,r,v*2+1);
}
void buildWall(int _n, int _k, int op[], int l[], int r[], int hei[], int ans[]) {
n = _n; k = _k;
init(0, n-1, 1);
for(int i = 0; i < k; ++i) {
if(op[i]-1) {
upd(l[i], r[i], 0, n-1, 1, {-INF, hei[i]});
} else {
upd(l[i], r[i], 0, n-1, 1, {hei[i], INF});
}
//tree(0,n-1,1);
//cout << "-----\n";
}
rec(0,n-1,1);
//tree(0,n-1,1);
//cout << "----\n";
for(int i = 0; i < n; ++i) {
ans[i] = res[i];
//cout << ans[i] << " ";
}
}
//int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
//cin >> n >> k;
//int op[k], l[k], r[k], hei[k], ans[n];
//for(int i = 0; i < k; ++i) {
//cin >> op[i] >> l[i] >> r[i] >> hei[i];
//}
//buildWall(n,k,op,l,r,hei,ans);
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
844 KB |
Output is correct |
5 |
Correct |
4 ms |
844 KB |
Output is correct |
6 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
129 ms |
8156 KB |
Output is correct |
3 |
Correct |
137 ms |
4260 KB |
Output is correct |
4 |
Correct |
440 ms |
11096 KB |
Output is correct |
5 |
Correct |
243 ms |
11684 KB |
Output is correct |
6 |
Correct |
241 ms |
11600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
6 ms |
844 KB |
Output is correct |
5 |
Correct |
4 ms |
844 KB |
Output is correct |
6 |
Correct |
4 ms |
780 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
128 ms |
9852 KB |
Output is correct |
9 |
Correct |
145 ms |
6088 KB |
Output is correct |
10 |
Correct |
440 ms |
13004 KB |
Output is correct |
11 |
Correct |
241 ms |
13436 KB |
Output is correct |
12 |
Correct |
225 ms |
13408 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
132 ms |
9928 KB |
Output is correct |
15 |
Correct |
33 ms |
2000 KB |
Output is correct |
16 |
Correct |
514 ms |
13200 KB |
Output is correct |
17 |
Correct |
249 ms |
13252 KB |
Output is correct |
18 |
Correct |
238 ms |
13180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
760 KB |
Output is correct |
5 |
Correct |
4 ms |
752 KB |
Output is correct |
6 |
Correct |
5 ms |
840 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
127 ms |
9928 KB |
Output is correct |
9 |
Correct |
141 ms |
5956 KB |
Output is correct |
10 |
Correct |
442 ms |
12996 KB |
Output is correct |
11 |
Correct |
241 ms |
13468 KB |
Output is correct |
12 |
Correct |
228 ms |
13392 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
131 ms |
9880 KB |
Output is correct |
15 |
Correct |
33 ms |
1992 KB |
Output is correct |
16 |
Correct |
508 ms |
13188 KB |
Output is correct |
17 |
Correct |
238 ms |
13128 KB |
Output is correct |
18 |
Correct |
240 ms |
13192 KB |
Output is correct |
19 |
Correct |
598 ms |
68664 KB |
Output is correct |
20 |
Correct |
585 ms |
64904 KB |
Output is correct |
21 |
Correct |
591 ms |
67564 KB |
Output is correct |
22 |
Correct |
585 ms |
64876 KB |
Output is correct |
23 |
Correct |
585 ms |
64912 KB |
Output is correct |
24 |
Correct |
583 ms |
64792 KB |
Output is correct |
25 |
Correct |
589 ms |
64808 KB |
Output is correct |
26 |
Correct |
587 ms |
67488 KB |
Output is correct |
27 |
Correct |
600 ms |
67440 KB |
Output is correct |
28 |
Correct |
581 ms |
64908 KB |
Output is correct |
29 |
Correct |
581 ms |
64876 KB |
Output is correct |
30 |
Correct |
582 ms |
64900 KB |
Output is correct |