# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
529069 |
2022-02-22T05:16:41 Z |
Gurban |
벽 (IOI14_wall) |
C++17 |
|
529 ms |
77408 KB |
#include "bits/stdc++.h"
#include "wall.h"
using namespace std;
using ll = long long;
const int maxn=2e6+5;
const int N = 5e5+5;
int T[4 * maxn][2];
void build(int l,int r,int nd){
T[nd][0] = T[nd][1] = -1;
if(l == r){
T[nd][0] = 0;
T[nd][1] = 0;
return;
}
int md = (l + r) >> 1;
build(l,md,nd<<1);
build(md+1,r,nd<<1 | 1);
}
void prop(int nd){
if(T[nd][0] == -1) return;
int cep = (nd << 1);
int sag = (nd << 1 | 1);
if(T[cep][0] == -1){
T[cep][0] = T[nd][0];
T[cep][1] = T[nd][1];
}
else if(T[cep][0] > T[nd][1]){
T[cep][0] = T[nd][1];
T[cep][1] = T[nd][1];
}
else if(T[cep][1] < T[nd][0]){
T[cep][0] = T[nd][0];
T[cep][1] = T[nd][0];
}
else {
T[cep][0] = max(T[cep][0],T[nd][0]);
T[cep][1] = min(T[cep][1],T[nd][1]);
}
if(T[sag][0] == -1){
T[sag][0] = T[nd][0];
T[sag][1] = T[nd][1];
}
else if(T[sag][0] > T[nd][1]){
T[sag][0] = T[nd][1];
T[sag][1] = T[nd][1];
}
else if(T[sag][1] < T[nd][0]){
T[sag][0] = T[nd][0];
T[sag][1] = T[nd][0];
}
else {
T[sag][0] = max(T[sag][0],T[nd][0]);
T[sag][1] = min(T[sag][1],T[nd][1]);
}
T[nd][0] = -1;
T[nd][1] = -1;
}
void upd(int a,int b,int lft,int rgt,int l,int r,int nd){
if(r < a or l > b) return;
if(l >= a and r <= b){
if(T[nd][0] == -1){
T[nd][0] = lft;
T[nd][1] = rgt;
return;
}
if(rgt < T[nd][0]){
T[nd][0] = rgt;
T[nd][1] = rgt;
}
else if(lft > T[nd][1]){
T[nd][0] = lft;
T[nd][1] = lft;
}
else {
T[nd][0] = max(T[nd][0],lft);
T[nd][1] = min(T[nd][1],rgt);
}
return;
}
prop(nd);
int md = (l + r) >> 1;
upd(a,b,lft,rgt,l,md,nd<<1);
upd(a,b,lft,rgt,md+1,r,nd<<1 | 1);
}
int jog[maxn];
void f(int l,int r,int nd){
if(l == r){
jog[l] = T[nd][0];
return;
}
prop(nd);
int md = (l + r) >> 1;
f(l,md,nd<<1);
f(md+1,r,nd<<1 | 1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
build(0,n-1,1);
for(int i = 0;i < k;i++){
if(op[i] == 2) upd(left[i],right[i],0,height[i],0,n-1,1);
else upd(left[i],right[i],height[i],1e5,0,n-1,1);
}
f(0,n-1,1);
for(int i = 0;i < n;i++) finalHeight[i] = jog[i];
return;
}
// int n,k;
// int op[N],l[N],r[N],h[N],ans[maxn];
// int main(){
// cin >> n >> k;
// for(int i = 0;i < k;i++) cin >> op[i] >> l[i] >> r[i] >> h[i];
// buildWall(n,k,op,l,r,h,ans);
// for(int i = 0;i < n;i++) cout<<ans[i]<<' ';
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
5 ms |
716 KB |
Output is correct |
5 |
Correct |
4 ms |
716 KB |
Output is correct |
6 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
132 ms |
8128 KB |
Output is correct |
3 |
Correct |
152 ms |
4216 KB |
Output is correct |
4 |
Correct |
431 ms |
11108 KB |
Output is correct |
5 |
Correct |
213 ms |
11624 KB |
Output is correct |
6 |
Correct |
213 ms |
11724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
716 KB |
Output is correct |
5 |
Correct |
5 ms |
716 KB |
Output is correct |
6 |
Correct |
4 ms |
844 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
131 ms |
13872 KB |
Output is correct |
9 |
Correct |
154 ms |
8004 KB |
Output is correct |
10 |
Correct |
432 ms |
20720 KB |
Output is correct |
11 |
Correct |
225 ms |
21772 KB |
Output is correct |
12 |
Correct |
216 ms |
20244 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
136 ms |
13836 KB |
Output is correct |
15 |
Correct |
28 ms |
1988 KB |
Output is correct |
16 |
Correct |
491 ms |
21072 KB |
Output is correct |
17 |
Correct |
228 ms |
20420 KB |
Output is correct |
18 |
Correct |
227 ms |
20452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
716 KB |
Output is correct |
5 |
Correct |
4 ms |
716 KB |
Output is correct |
6 |
Correct |
4 ms |
816 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
131 ms |
13868 KB |
Output is correct |
9 |
Correct |
153 ms |
8008 KB |
Output is correct |
10 |
Correct |
447 ms |
20844 KB |
Output is correct |
11 |
Correct |
217 ms |
21748 KB |
Output is correct |
12 |
Correct |
217 ms |
20248 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
141 ms |
13932 KB |
Output is correct |
15 |
Correct |
28 ms |
1956 KB |
Output is correct |
16 |
Correct |
489 ms |
20972 KB |
Output is correct |
17 |
Correct |
226 ms |
20444 KB |
Output is correct |
18 |
Correct |
234 ms |
20548 KB |
Output is correct |
19 |
Correct |
527 ms |
77252 KB |
Output is correct |
20 |
Correct |
513 ms |
74808 KB |
Output is correct |
21 |
Correct |
522 ms |
77284 KB |
Output is correct |
22 |
Correct |
516 ms |
74868 KB |
Output is correct |
23 |
Correct |
518 ms |
74868 KB |
Output is correct |
24 |
Correct |
526 ms |
74892 KB |
Output is correct |
25 |
Correct |
509 ms |
74820 KB |
Output is correct |
26 |
Correct |
519 ms |
77408 KB |
Output is correct |
27 |
Correct |
513 ms |
77252 KB |
Output is correct |
28 |
Correct |
513 ms |
74924 KB |
Output is correct |
29 |
Correct |
527 ms |
74836 KB |
Output is correct |
30 |
Correct |
529 ms |
74896 KB |
Output is correct |