# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
742186 |
2023-05-15T17:58:39 Z |
vjudge1 |
Wall (IOI14_wall) |
C++17 |
|
731 ms |
69580 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
const int INF=INT_MAX;
const int t=(1<<21);
pair<int, int> tree[2*t-1];
void propagate(int x)
{
if (2*x+2>=2*t-1)
return;
tree[2*x+1].first=min(tree[2*x+1].first, tree[x].first);
tree[2*x+1].second=min(tree[2*x+1].second, tree[2*x+1].first);
tree[2*x+1].second=max(tree[2*x+1].second, tree[x].second);
tree[2*x+1].first=max(tree[2*x+1].first, tree[2*x+1].second);
tree[2*x+2].first=min(tree[2*x+2].first, tree[x].first);
tree[2*x+2].second=min(tree[2*x+2].second, tree[2*x+2].first);
tree[2*x+2].second=max(tree[2*x+2].second, tree[x].second);
tree[2*x+2].first=max(tree[2*x+2].first, tree[2*x+2].second);
tree[x]={INF, -INF};
return;
}
void adding(int x, int l, int r, int lt, int rt, int value)
{
if (r<=lt || l>=rt)
return;
propagate(x);
if (l>=lt && r<=rt)
{
tree[x].second=max(tree[x].second, value);
tree[x].first=max(tree[x].first, tree[x].second);
return;
}
adding(2*x+1, l, (l+r)/2, lt, rt, value);
adding(2*x+2, (l+r)/2, r, lt, rt, value);
return;
}
void removing(int x, int l, int r, int lt, int rt, int value)
{
if (r<=lt || l>=rt)
return;
propagate(x);
if (l>=lt && r<=rt)
{
tree[x].first=min(tree[x].first, value);
tree[x].second=min(tree[x].second, tree[x].first);
return;
}
removing(2*x+1, l, (l+r)/2, lt, rt, value);
removing(2*x+2, (l+r)/2, r, lt, rt, value);
return;
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for (int i=0; i<2*t-1; i++)
tree[i]={INF, -INF};
for (int i=0; i<k; i++)
{
if (op[i]==1)
adding(0, 0, t, left[i], right[i]+1, height[i]);
if (op[i]==2)
removing(0, 0, t, left[i], right[i]+1, height[i]);
}
for (int i=0; i<2*t-1; i++)
propagate(i);
for (int i=0; i<n; i++)
finalHeight[i]=max(tree[i+t-1].second, 0);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
33108 KB |
Output is correct |
2 |
Correct |
37 ms |
33256 KB |
Output is correct |
3 |
Correct |
35 ms |
33228 KB |
Output is correct |
4 |
Correct |
37 ms |
33268 KB |
Output is correct |
5 |
Correct |
36 ms |
33288 KB |
Output is correct |
6 |
Correct |
35 ms |
33356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
33108 KB |
Output is correct |
2 |
Correct |
268 ms |
40960 KB |
Output is correct |
3 |
Correct |
176 ms |
36440 KB |
Output is correct |
4 |
Correct |
467 ms |
51080 KB |
Output is correct |
5 |
Correct |
296 ms |
52188 KB |
Output is correct |
6 |
Correct |
294 ms |
50580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
33088 KB |
Output is correct |
2 |
Correct |
36 ms |
33196 KB |
Output is correct |
3 |
Correct |
32 ms |
33140 KB |
Output is correct |
4 |
Correct |
36 ms |
33280 KB |
Output is correct |
5 |
Correct |
38 ms |
33356 KB |
Output is correct |
6 |
Correct |
37 ms |
33452 KB |
Output is correct |
7 |
Correct |
32 ms |
33108 KB |
Output is correct |
8 |
Correct |
273 ms |
46768 KB |
Output is correct |
9 |
Correct |
198 ms |
40216 KB |
Output is correct |
10 |
Correct |
433 ms |
51192 KB |
Output is correct |
11 |
Correct |
298 ms |
52104 KB |
Output is correct |
12 |
Correct |
303 ms |
50552 KB |
Output is correct |
13 |
Correct |
31 ms |
33112 KB |
Output is correct |
14 |
Correct |
283 ms |
46864 KB |
Output is correct |
15 |
Correct |
61 ms |
34300 KB |
Output is correct |
16 |
Correct |
464 ms |
51356 KB |
Output is correct |
17 |
Correct |
324 ms |
50812 KB |
Output is correct |
18 |
Correct |
313 ms |
50756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
33108 KB |
Output is correct |
2 |
Correct |
33 ms |
33224 KB |
Output is correct |
3 |
Correct |
39 ms |
33136 KB |
Output is correct |
4 |
Correct |
38 ms |
33316 KB |
Output is correct |
5 |
Correct |
35 ms |
33356 KB |
Output is correct |
6 |
Correct |
45 ms |
33328 KB |
Output is correct |
7 |
Correct |
32 ms |
33108 KB |
Output is correct |
8 |
Correct |
276 ms |
46740 KB |
Output is correct |
9 |
Correct |
182 ms |
40224 KB |
Output is correct |
10 |
Correct |
431 ms |
51084 KB |
Output is correct |
11 |
Correct |
343 ms |
52088 KB |
Output is correct |
12 |
Correct |
297 ms |
50600 KB |
Output is correct |
13 |
Correct |
43 ms |
33004 KB |
Output is correct |
14 |
Correct |
307 ms |
46768 KB |
Output is correct |
15 |
Correct |
55 ms |
34260 KB |
Output is correct |
16 |
Correct |
429 ms |
51336 KB |
Output is correct |
17 |
Correct |
298 ms |
50760 KB |
Output is correct |
18 |
Correct |
296 ms |
50756 KB |
Output is correct |
19 |
Correct |
672 ms |
69572 KB |
Output is correct |
20 |
Correct |
616 ms |
66976 KB |
Output is correct |
21 |
Correct |
617 ms |
69580 KB |
Output is correct |
22 |
Correct |
633 ms |
66996 KB |
Output is correct |
23 |
Correct |
625 ms |
67024 KB |
Output is correct |
24 |
Correct |
628 ms |
67012 KB |
Output is correct |
25 |
Correct |
633 ms |
67148 KB |
Output is correct |
26 |
Correct |
639 ms |
69516 KB |
Output is correct |
27 |
Correct |
731 ms |
69468 KB |
Output is correct |
28 |
Correct |
654 ms |
66884 KB |
Output is correct |
29 |
Correct |
618 ms |
66932 KB |
Output is correct |
30 |
Correct |
628 ms |
67012 KB |
Output is correct |