답안 #745593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745593 2023-05-20T14:28:35 Z Username4132 벽 (IOI14_wall) C++14
61 / 100
473 ms 58480 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=1000010, 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 320 KB Output is correct
4 Correct 6 ms 704 KB Output is correct
5 Correct 5 ms 704 KB Output is correct
6 Correct 6 ms 708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 135 ms 8264 KB Output is correct
3 Correct 153 ms 7676 KB Output is correct
4 Correct 393 ms 19928 KB Output is correct
5 Correct 325 ms 20884 KB Output is correct
6 Correct 309 ms 19416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 444 KB Output is correct
3 Correct 2 ms 316 KB Output is correct
4 Correct 7 ms 704 KB Output is correct
5 Correct 5 ms 724 KB Output is correct
6 Correct 5 ms 644 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 139 ms 13916 KB Output is correct
9 Correct 162 ms 7676 KB Output is correct
10 Correct 390 ms 19916 KB Output is correct
11 Correct 323 ms 20944 KB Output is correct
12 Correct 312 ms 19316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 144 ms 13940 KB Output is correct
15 Correct 29 ms 1656 KB Output is correct
16 Correct 473 ms 20188 KB Output is correct
17 Correct 323 ms 19568 KB Output is correct
18 Correct 318 ms 19516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 2 ms 320 KB Output is correct
4 Correct 6 ms 724 KB Output is correct
5 Correct 5 ms 696 KB Output is correct
6 Correct 5 ms 636 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 142 ms 13864 KB Output is correct
9 Correct 150 ms 7704 KB Output is correct
10 Correct 388 ms 19844 KB Output is correct
11 Correct 318 ms 20920 KB Output is correct
12 Correct 314 ms 19316 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 148 ms 13944 KB Output is correct
15 Correct 29 ms 1768 KB Output is correct
16 Correct 453 ms 20144 KB Output is correct
17 Correct 321 ms 19508 KB Output is correct
18 Correct 321 ms 19528 KB Output is correct
19 Runtime error 180 ms 58480 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -