# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
307290 |
2020-09-27T14:44:17 Z |
tengiz05 |
Wall (IOI14_wall) |
C++17 |
|
1108 ms |
49016 KB |
#include "wall.h"
#include <bits/stdc++.h>
using namespace std;
struct segtree {
struct Node {
int min;
int max;
};
vector<Node> t;
int no_max = INT_MAX;
int no_min = 0;
int sz;
void init(int n){
sz = 1;
while(sz < n)sz <<= 1;
t.assign(sz*2, {0, 0});
}
void modify(int Max, int Min, int node){
t[node].max = min(Max, max(Min, t[node].max));
t[node].min = min(Max, max(Min, t[node].min));
}
void push(int node, int len){
if(len == 1){
t[node] = {no_min, no_max};
return;
}
modify(t[node].max, t[node].min, node*2);
modify(t[node].max, t[node].min, node*2+1);
t[node] = {no_min, no_max};
}
void add(int l, int r, int L, int R, int node, int Max, int Min){
if(L >= r || R <= l)return;
if(L >= l && R <= r){
modify(Max, Min, node);
return;
}push(node, R-L);
int mid = (L+R)/2;
add(l, r, L, mid, node*2, Max, Min);
add(l, r, mid, R, node*2+1,Max,Min);
}
void add(int l, int r, int Max, int Min){
add(l, r, 0, sz, 1, Max, Min);
}
int get(int i, int L, int R, int node){
if(R-L == 1){
return t[node].min;
}
push(node, R-L);
int mid = (L+R)/2;
if(i < mid)return get(i, L, mid, node*2);
else return get(i, mid, R, node*2+1);
}int get(int i){
int ans = max(get(i, 0, sz, 1), 0);
return ans;
}
/*
void print(){
cout << '\n';
for(int i=1;i<sz*2;i++){
cout << t[i].min << ' ' << t[i].max << '\n';
}cout << "\n\n";
}*/
};
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
segtree seg;
seg.init(n);
for(int i=0;i<k;i++){
// seg.print();
if(op[i] == 2){
// add
seg.add(left[i], right[i]+1, height[i], seg.no_min);
}else {
// remove
seg.add(left[i], right[i]+1, seg.no_max, height[i]);
}
}//seg.print();
for(int i=0;i<n;i++){
finalHeight[i] = seg.get(i);
// seg.print();
}
return;
}
/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
640 KB |
Output is correct |
5 |
Correct |
7 ms |
640 KB |
Output is correct |
6 |
Correct |
7 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
170 ms |
8312 KB |
Output is correct |
3 |
Correct |
196 ms |
4216 KB |
Output is correct |
4 |
Correct |
548 ms |
10616 KB |
Output is correct |
5 |
Correct |
336 ms |
10616 KB |
Output is correct |
6 |
Correct |
326 ms |
10616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
640 KB |
Output is correct |
5 |
Correct |
7 ms |
640 KB |
Output is correct |
6 |
Correct |
7 ms |
640 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
172 ms |
8228 KB |
Output is correct |
9 |
Correct |
192 ms |
4220 KB |
Output is correct |
10 |
Correct |
577 ms |
10744 KB |
Output is correct |
11 |
Correct |
338 ms |
10744 KB |
Output is correct |
12 |
Correct |
324 ms |
10744 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
170 ms |
8184 KB |
Output is correct |
15 |
Correct |
33 ms |
1400 KB |
Output is correct |
16 |
Correct |
537 ms |
10744 KB |
Output is correct |
17 |
Correct |
329 ms |
10696 KB |
Output is correct |
18 |
Correct |
330 ms |
10620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
640 KB |
Output is correct |
5 |
Correct |
8 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
170 ms |
8184 KB |
Output is correct |
9 |
Correct |
192 ms |
4216 KB |
Output is correct |
10 |
Correct |
551 ms |
10572 KB |
Output is correct |
11 |
Correct |
337 ms |
10744 KB |
Output is correct |
12 |
Correct |
324 ms |
10616 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
176 ms |
8184 KB |
Output is correct |
15 |
Correct |
34 ms |
1400 KB |
Output is correct |
16 |
Correct |
571 ms |
10752 KB |
Output is correct |
17 |
Correct |
332 ms |
10748 KB |
Output is correct |
18 |
Correct |
324 ms |
10616 KB |
Output is correct |
19 |
Correct |
1108 ms |
48760 KB |
Output is correct |
20 |
Correct |
1107 ms |
48888 KB |
Output is correct |
21 |
Correct |
1101 ms |
48888 KB |
Output is correct |
22 |
Correct |
1088 ms |
48864 KB |
Output is correct |
23 |
Correct |
1107 ms |
48888 KB |
Output is correct |
24 |
Correct |
1091 ms |
48888 KB |
Output is correct |
25 |
Correct |
1089 ms |
48892 KB |
Output is correct |
26 |
Correct |
1093 ms |
48760 KB |
Output is correct |
27 |
Correct |
1097 ms |
48888 KB |
Output is correct |
28 |
Correct |
1092 ms |
49016 KB |
Output is correct |
29 |
Correct |
1093 ms |
48888 KB |
Output is correct |
30 |
Correct |
1086 ms |
48888 KB |
Output is correct |