# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
754446 |
2023-06-07T19:09:44 Z |
A_D |
벽 (IOI14_wall) |
C++17 |
|
842 ms |
99336 KB |
#include "wall.h"
#include <bits/stdc++.h>
#define ii pair<int,int>
#define F first
#define S second
using namespace std;
const int N=2e6+100;
int mn[4*N];
int mx[4*N];
ii com(ii a, ii b)
{
if(a.S<b.F){
return {a.S,a.S};
}
if(b.S<a.F){
return {a.F,a.F};
}
if(a.F<=b.F&&b.S<=a.S){
return b;
}
if(b.F<=a.F&&a.S<=b.S){
return a;
}
return make_pair(max(a.F,b.F),min(a.S,b.S));
}
void update(int p,int s,int e,int a,int b,int h,int t,ii v)
{
v=com(v,{mn[p],mx[p]});
mn[p]=v.F;
mx[p]=v.S;
if(a<=s&&e<=b){
if(t==1){
mn[p]=max(mn[p],h);
if(mn[p]>mx[p]){
mx[p]=mn[p];
}
}
else{
mx[p]=min(mx[p],h);
if(mx[p]<mn[p]){
mn[p]=mx[p];
}
}
return;
}
if(a>e || b<s){
return;
}
mn[p]=0;
mx[p]=1e5;
int mid=(s+e)/2;
update(p*2,s,mid,a,b,h,t,v);
update(p*2+1,mid+1,e,a,b,h,t,v);
}
int get(int p,int s,int e,int i,ii v)
{
v=com(v,{mn[p],mx[p]});
if(s==e){
return v.F;
}
int mid=(s+e)/2;
if(i<=mid){
return get(p*2,s,mid,i,v);
}
else{
return get(p*2+1,mid+1,e,i,v);
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i=0;i<4*n;i++){
mn[i]=0;
mx[i]=1e5;
}
for(int i=0;i<k;i++){
update(1,0,n-1,left[i],right[i],height[i],op[i],make_pair(0,1e5));
}
for(int i=0;i<n;i++){
finalHeight[i]=get(1,0,n-1,i,{0,1e5});
}
//cout<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
852 KB |
Output is correct |
5 |
Correct |
5 ms |
832 KB |
Output is correct |
6 |
Correct |
7 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
140 ms |
8748 KB |
Output is correct |
3 |
Correct |
198 ms |
4812 KB |
Output is correct |
4 |
Correct |
503 ms |
12680 KB |
Output is correct |
5 |
Correct |
301 ms |
13200 KB |
Output is correct |
6 |
Correct |
270 ms |
13280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
852 KB |
Output is correct |
5 |
Correct |
5 ms |
828 KB |
Output is correct |
6 |
Correct |
6 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
144 ms |
13900 KB |
Output is correct |
9 |
Correct |
187 ms |
7968 KB |
Output is correct |
10 |
Correct |
499 ms |
21388 KB |
Output is correct |
11 |
Correct |
291 ms |
22460 KB |
Output is correct |
12 |
Correct |
311 ms |
20892 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
141 ms |
13884 KB |
Output is correct |
15 |
Correct |
42 ms |
2128 KB |
Output is correct |
16 |
Correct |
588 ms |
21728 KB |
Output is correct |
17 |
Correct |
332 ms |
21196 KB |
Output is correct |
18 |
Correct |
273 ms |
21072 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
308 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
852 KB |
Output is correct |
5 |
Correct |
5 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
852 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
143 ms |
13896 KB |
Output is correct |
9 |
Correct |
211 ms |
7980 KB |
Output is correct |
10 |
Correct |
570 ms |
21484 KB |
Output is correct |
11 |
Correct |
291 ms |
22448 KB |
Output is correct |
12 |
Correct |
264 ms |
20940 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
189 ms |
13940 KB |
Output is correct |
15 |
Correct |
35 ms |
2024 KB |
Output is correct |
16 |
Correct |
575 ms |
21672 KB |
Output is correct |
17 |
Correct |
275 ms |
21072 KB |
Output is correct |
18 |
Correct |
280 ms |
21096 KB |
Output is correct |
19 |
Correct |
806 ms |
99288 KB |
Output is correct |
20 |
Correct |
818 ms |
96804 KB |
Output is correct |
21 |
Correct |
823 ms |
99316 KB |
Output is correct |
22 |
Correct |
773 ms |
96708 KB |
Output is correct |
23 |
Correct |
752 ms |
96964 KB |
Output is correct |
24 |
Correct |
749 ms |
96940 KB |
Output is correct |
25 |
Correct |
766 ms |
96784 KB |
Output is correct |
26 |
Correct |
842 ms |
99336 KB |
Output is correct |
27 |
Correct |
781 ms |
99300 KB |
Output is correct |
28 |
Correct |
822 ms |
96692 KB |
Output is correct |
29 |
Correct |
750 ms |
96824 KB |
Output is correct |
30 |
Correct |
812 ms |
96820 KB |
Output is correct |