# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
986900 |
2024-05-21T14:09:21 Z |
vjudge1 |
벽 (IOI14_wall) |
C++17 |
|
794 ms |
223572 KB |
#include <bits/stdc++.h>
#include "wall.h"
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1 << 23;
int add[N << 2], del[N << 2];
void push(int i, int l, int r){
if(l != r){
add[i << 1] = min(add[i << 1], del[i]);
add[i << 1] = max(add[i << 1], add[i]);
del[i << 1] = min(del[i << 1], del[i]);
del[i << 1] = max(del[i << 1], add[i]);
add[i << 1 | 1] = min(add[i << 1 | 1], del[i]);
add[i << 1 | 1] = max(add[i << 1 | 1], add[i]);
del[i << 1 | 1] = min(del[i << 1 | 1], del[i]);
del[i << 1 | 1] = max(del[i << 1 | 1], add[i]);
add[i] = 0, del[i] = INF;
}
}
void updAdd(int l, int r, int i, int from, int to, int val){
push(i, from, to);
if (from > r || to < l)
return;
if (from >= l && to <= r)
{
add[i] = max(add[i], val);
del[i] = max(del[i], val);
push(i, from, to);
return;
}
int mid = (from + to) >> 1;
updAdd(l, r, i << 1, from, mid, val);
updAdd(l, r, i << 1 | 1, mid + 1, to, val);
}
void updDel(int l, int r, int i, int from, int to, int val){
push(i, from, to);
if(from > r || to < l) return;
if(from >= l && to <= r){
add[i] = min(add[i], val);
del[i] = min(del[i], val);
push(i, from, to);
return;
}
int mid = (from + to) >> 1;
updDel(l, r, i << 1, from, mid, val);
updDel(l, r, i << 1 | 1, mid + 1, to , val);
}
void pushall(int i, int l, int r){
if(l == r) return;
push(i, l, r);
int mid = (l + r) >> 1;
pushall(i << 1, l, mid);
pushall(i << 1 | 1, mid + 1, r);
}
void buildWall(int n, int k, int op[], int l[], int r[], int h[], int ans[]){
memset(del, INF, sizeof del);
for(int i = 0; i < k; i++){
if(op[i] == 1){
updAdd(l[i], r[i], 1, 0, N - 1, h[i]);
}
else{
updDel(l[i], r[i], 1, 0, N - 1, h[i]);
}
}
pushall(1, 0, N - 1);
for(int i = 0; i < n; i++){
ans[i] = min(add[i + N], del[i + N]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
133 ms |
197272 KB |
Output is correct |
2 |
Correct |
127 ms |
197456 KB |
Output is correct |
3 |
Correct |
143 ms |
197456 KB |
Output is correct |
4 |
Correct |
135 ms |
197712 KB |
Output is correct |
5 |
Correct |
130 ms |
197504 KB |
Output is correct |
6 |
Correct |
130 ms |
197444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
197200 KB |
Output is correct |
2 |
Correct |
413 ms |
205136 KB |
Output is correct |
3 |
Correct |
334 ms |
200788 KB |
Output is correct |
4 |
Correct |
602 ms |
205652 KB |
Output is correct |
5 |
Correct |
428 ms |
206264 KB |
Output is correct |
6 |
Correct |
424 ms |
206152 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
127 ms |
197304 KB |
Output is correct |
2 |
Correct |
129 ms |
197440 KB |
Output is correct |
3 |
Correct |
130 ms |
197248 KB |
Output is correct |
4 |
Correct |
130 ms |
197440 KB |
Output is correct |
5 |
Correct |
133 ms |
197552 KB |
Output is correct |
6 |
Correct |
130 ms |
197544 KB |
Output is correct |
7 |
Correct |
126 ms |
197284 KB |
Output is correct |
8 |
Correct |
409 ms |
205104 KB |
Output is correct |
9 |
Correct |
311 ms |
200716 KB |
Output is correct |
10 |
Correct |
633 ms |
206100 KB |
Output is correct |
11 |
Correct |
425 ms |
206212 KB |
Output is correct |
12 |
Correct |
420 ms |
206176 KB |
Output is correct |
13 |
Correct |
126 ms |
197260 KB |
Output is correct |
14 |
Correct |
407 ms |
205104 KB |
Output is correct |
15 |
Correct |
155 ms |
197972 KB |
Output is correct |
16 |
Correct |
624 ms |
206076 KB |
Output is correct |
17 |
Correct |
436 ms |
206268 KB |
Output is correct |
18 |
Correct |
446 ms |
206056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
126 ms |
197200 KB |
Output is correct |
2 |
Correct |
142 ms |
197456 KB |
Output is correct |
3 |
Correct |
126 ms |
197200 KB |
Output is correct |
4 |
Correct |
150 ms |
197536 KB |
Output is correct |
5 |
Correct |
135 ms |
197492 KB |
Output is correct |
6 |
Correct |
131 ms |
197456 KB |
Output is correct |
7 |
Correct |
128 ms |
197200 KB |
Output is correct |
8 |
Correct |
416 ms |
205224 KB |
Output is correct |
9 |
Correct |
307 ms |
200704 KB |
Output is correct |
10 |
Correct |
687 ms |
205680 KB |
Output is correct |
11 |
Correct |
458 ms |
206172 KB |
Output is correct |
12 |
Correct |
440 ms |
206160 KB |
Output is correct |
13 |
Correct |
129 ms |
197392 KB |
Output is correct |
14 |
Correct |
418 ms |
205140 KB |
Output is correct |
15 |
Correct |
155 ms |
198032 KB |
Output is correct |
16 |
Correct |
626 ms |
206068 KB |
Output is correct |
17 |
Correct |
446 ms |
206084 KB |
Output is correct |
18 |
Correct |
474 ms |
205892 KB |
Output is correct |
19 |
Correct |
792 ms |
223232 KB |
Output is correct |
20 |
Correct |
794 ms |
220636 KB |
Output is correct |
21 |
Correct |
776 ms |
223572 KB |
Output is correct |
22 |
Correct |
766 ms |
220756 KB |
Output is correct |
23 |
Correct |
764 ms |
220800 KB |
Output is correct |
24 |
Correct |
761 ms |
220728 KB |
Output is correct |
25 |
Correct |
761 ms |
220628 KB |
Output is correct |
26 |
Correct |
762 ms |
223388 KB |
Output is correct |
27 |
Correct |
771 ms |
223388 KB |
Output is correct |
28 |
Correct |
768 ms |
220884 KB |
Output is correct |
29 |
Correct |
769 ms |
220736 KB |
Output is correct |
30 |
Correct |
768 ms |
220728 KB |
Output is correct |