답안 #745594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745594 2023-05-20T14:30:45 Z Username4132 벽 (IOI14_wall) C++14
100 / 100
694 ms 67972 KB
#include "wall.h"

#include<iostream>
using namespace std;
using pii = pair<int, int>;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define F first
#define S second

const int MAXN=2000010, MAXH=100010;
int n, he;

pii combine(pii a, pii b){
  if(b.S<=a.F) return {b.S - 1, b.S};
  else if(a.S<=b.F) return {b.F, b.F + 1};
  else return {max(a.F, b.F), min(a.S, b.S)};
}

pii tr[2*MAXN];

void apply(int p, pii value){
  tr[p]=combine(tr[p], value);
}

void push(int p){
  for(int s=he; s>0; --s){
    int i=(p>>s);
    apply(i<<1, tr[i]);
    apply(i<<1|1, tr[i]);
    tr[i]={0, MAXH};
  }
}

void modify(int l, int r, pii value){
  l+=n, r+=n;
  push(l);
  push(r-1);
  for(; l<r; l>>=1, r>>=1){
    if(l&1) apply(l++, value);
    if(r&1) apply(--r, value);
  }
}

void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
  n=N; he=8*sizeof(int) - __builtin_clz(n);
  forn(i, 2*n) tr[i]={0, MAXH};
  forn(i, k){
    pii interval = op[i]==1? make_pair(height[i], MAXH) : make_pair(0, height[i]+1);
    modify(left[i], right[i]+1, interval);
  }
  for(int i=1; i<n; ++i){
    apply(i<<1, tr[i]);
    apply(i<<1|1, tr[i]);
    tr[i]={0, MAXH};
  }
  forn(i, n) finalHeight[i]=tr[n+i].F;
  return;
}
# 결과 실행 시간 메모리 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 6 ms 664 KB Output is correct
5 Correct 5 ms 708 KB Output is correct
6 Correct 5 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 138 ms 8324 KB Output is correct
3 Correct 190 ms 4236 KB Output is correct
4 Correct 411 ms 10480 KB Output is correct
5 Correct 325 ms 11016 KB Output is correct
6 Correct 338 ms 11016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 8 ms 668 KB Output is correct
5 Correct 5 ms 712 KB Output is correct
6 Correct 5 ms 724 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 173 ms 8452 KB Output is correct
9 Correct 146 ms 4140 KB Output is correct
10 Correct 379 ms 10476 KB Output is correct
11 Correct 347 ms 10952 KB Output is correct
12 Correct 309 ms 10988 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 149 ms 8312 KB Output is correct
15 Correct 30 ms 1348 KB Output is correct
16 Correct 494 ms 10728 KB Output is correct
17 Correct 338 ms 10788 KB Output is correct
18 Correct 328 ms 10732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 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 712 KB Output is correct
5 Correct 5 ms 724 KB Output is correct
6 Correct 5 ms 680 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 172 ms 8392 KB Output is correct
9 Correct 170 ms 4220 KB Output is correct
10 Correct 396 ms 10568 KB Output is correct
11 Correct 329 ms 11084 KB Output is correct
12 Correct 384 ms 10968 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 138 ms 8396 KB Output is correct
15 Correct 29 ms 1456 KB Output is correct
16 Correct 471 ms 10764 KB Output is correct
17 Correct 326 ms 10600 KB Output is correct
18 Correct 377 ms 10664 KB Output is correct
19 Correct 629 ms 57476 KB Output is correct
20 Correct 640 ms 65564 KB Output is correct
21 Correct 640 ms 67972 KB Output is correct
22 Correct 653 ms 65432 KB Output is correct
23 Correct 647 ms 65492 KB Output is correct
24 Correct 635 ms 65452 KB Output is correct
25 Correct 652 ms 65372 KB Output is correct
26 Correct 637 ms 67920 KB Output is correct
27 Correct 694 ms 67928 KB Output is correct
28 Correct 619 ms 65488 KB Output is correct
29 Correct 631 ms 65492 KB Output is correct
30 Correct 660 ms 65492 KB Output is correct