답안 #597472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597472 2022-07-16T05:00:59 Z chirathnirodha 벽 (IOI14_wall) C++17
100 / 100
613 ms 118100 KB
#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first 
#define S second
#define P push
typedef long long ll;
const int maxn=2000000;
ll mini[maxn*4];
ll maxi[maxn*4];
ll finh[maxn];
void update_seg(ll c,ll l,ll h){
  if(maxi[c]<=l)mini[c]=maxi[c]=l;
  else if(mini[c]>=h)mini[c]=maxi[c]=h;
  else{
    maxi[c]=min(maxi[c],h);
    mini[c]=max(mini[c],l);
  }
}
void update(ll a,ll b,ll c,ll l,ll h,ll x,ll y){
  if(a==x && b==y){
    update_seg(c,l,h);
    return;
  }
  update_seg(2*c,mini[c],maxi[c]);
  update_seg(2*c+1,mini[c],maxi[c]);
  mini[c]=0;maxi[c]=INT32_MAX;
  ll m=(a+b)/2;
  if(y<=m)update(a,m,2*c,l,h,x,y);
  else if(x>m)update(m+1,b,2*c+1,l,h,x,y);
  else{
    update(a,m,2*c,l,h,x,m);
    update(m+1,b,2*c+1,l,h,m+1,y);
  }
}
void finalize(ll a,ll b,ll c){
  if(a==b){finh[a]=mini[c];return;}
  ll m=(a+b)/2;
  update_seg(2*c,mini[c],maxi[c]);
  update_seg(2*c+1,mini[c],maxi[c]);
  finalize(a,m,2*c);
  finalize(m+1,b,2*c+1);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  for(int i=0;i<k;i++){
    if(op[i]==1)update(0,n-1,1,height[i],INT32_MAX,left[i],right[i]);
    else update(0,n-1,1,0,height[i],left[i],right[i]);
  }
  finalize(0,n-1,1);
  for(int i=0;i<n;i++)finalHeight[i]=finh[i];
  return;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 448 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 9 ms 1148 KB Output is correct
5 Correct 5 ms 1108 KB Output is correct
6 Correct 5 ms 1088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 132 ms 13872 KB Output is correct
3 Correct 135 ms 8556 KB Output is correct
4 Correct 360 ms 23148 KB Output is correct
5 Correct 288 ms 24204 KB Output is correct
6 Correct 228 ms 22608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 5 ms 1108 KB Output is correct
6 Correct 4 ms 1088 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 135 ms 14036 KB Output is correct
9 Correct 134 ms 8516 KB Output is correct
10 Correct 410 ms 23212 KB Output is correct
11 Correct 241 ms 24372 KB Output is correct
12 Correct 232 ms 22640 KB Output is correct
13 Correct 1 ms 224 KB Output is correct
14 Correct 127 ms 13900 KB Output is correct
15 Correct 28 ms 2612 KB Output is correct
16 Correct 487 ms 23488 KB Output is correct
17 Correct 244 ms 22796 KB Output is correct
18 Correct 265 ms 22820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 6 ms 1088 KB Output is correct
5 Correct 5 ms 1092 KB Output is correct
6 Correct 4 ms 1108 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 129 ms 13860 KB Output is correct
9 Correct 133 ms 8560 KB Output is correct
10 Correct 379 ms 23148 KB Output is correct
11 Correct 246 ms 24200 KB Output is correct
12 Correct 234 ms 22636 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 131 ms 13892 KB Output is correct
15 Correct 27 ms 2548 KB Output is correct
16 Correct 458 ms 23400 KB Output is correct
17 Correct 237 ms 22864 KB Output is correct
18 Correct 240 ms 22860 KB Output is correct
19 Correct 605 ms 118100 KB Output is correct
20 Correct 606 ms 115528 KB Output is correct
21 Correct 602 ms 117956 KB Output is correct
22 Correct 602 ms 115432 KB Output is correct
23 Correct 603 ms 115424 KB Output is correct
24 Correct 613 ms 115404 KB Output is correct
25 Correct 590 ms 115388 KB Output is correct
26 Correct 591 ms 117936 KB Output is correct
27 Correct 612 ms 117940 KB Output is correct
28 Correct 596 ms 115524 KB Output is correct
29 Correct 602 ms 115404 KB Output is correct
30 Correct 608 ms 115492 KB Output is correct