답안 #892898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892898 2023-12-26T06:46:39 Z Mr_Husanboy 벽 (IOI14_wall) C++17
컴파일 오류
0 ms 0 KB
#include "wall.h"
#include <bits/stdc++.h>

using namespace std;
const int inf = 1e9;



struct Segtree{
  struct Node{
    int mn = inf, mx = 0;
    void apply(int x, int type){
      if(type == 1){
        mn = max(mn, x);
        mx = max(mx, x);
      }else{
        mn = min(mn, x);
        mx = min(mx, x);
      }
    }
    void calibrate(){
      mn = inf, mx = 0;
    }
  };
  vector<Node> t;
  int n;

  void init(int _n){
    n = _n;
    t.resize(4 * n);
  }

  void push(int x){
    t[x * 2].apply(t[x].mx, 1);
    t[x * 2].apply(t[x].mn, 2);
    t[x * 2 + 1].apply(t[x].mx, 1);
    t[x * 2 + 1].apply(t[x].mn, 2);
    t[x].calibrate();
  }

  void upd(int x, int l, int r, int ql, int qr, int val, int type){
    if(l > qr || ql > r) return;
    if(ql <= l && r <= qr){
      //cout << l << ' ' << r << ' ' << val << ' ' << type << endl;

      t[x].apply(val, type);
     // cout << t[x].mx << endl;
      return;
    } 
    push(x);
    int m = (l + r) / 2;
    upd(x * 2, l, m, ql, qr, val, type);
    upd(x * 2 + 1, m + 1, r, ql, qr, val, type);
  }

  int get(int x, int l, int r, int ind){
    if(l == r){
      return t[x].mx;
    }
    push(x);
    int m = (l + r) / 2;
    if(ind <= m) return get(x * 2, l, m, ind);
    else return get(x * 2 + 1, m + 1, r, ind);
  }

  //interface

  void upd(int l, int r, int val, int type){
    upd(1, 0, n - 1, l, r, val, type);
  }

  int get(int ind){
    finish(1, 0, n - 1, ind);
  }
};

void buildWall(int n, int k, int op[], int left[], int right[], int height[], int ans[]){
    Segtree t;
    t.init(n);
    for(int i = 0; i < k; i ++){
      t.upd(left[i], right[i], height[i], op[i]);
    }
    for(int i = 0; i < n; i ++) ans[i] = t.get(i);
}

Compilation message

wall.cpp: In member function 'int Segtree::get(int)':
wall.cpp:73:5: error: 'finish' was not declared in this scope; did you mean 'finite'?
   73 |     finish(1, 0, n - 1, ind);
      |     ^~~~~~
      |     finite
wall.cpp:74:3: warning: no return statement in function returning non-void [-Wreturn-type]
   74 |   }
      |   ^