Submission #572268

# Submission time Handle Problem Language Result Execution time Memory
572268 2022-06-04T07:29:52 Z SSRS Weighting stones (IZhO11_stones) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
struct lazy_segment_tree{
  int N;
  vector<int> mn, mx, lazy;
  lazy_segment_tree(int N2){
    N = 1;
    while (N < N2){
      N *= 2;
    }
    mn = vector<int>(N * 2 - 1, INF);
    mx = vector<int>(N * 2 - 1, -INF);
    for (int i = 0; i < N2; i++){
      mn[N - 1 + i] = 0;
      mx[N - 1 + i] = 0;
    }
    for (int i = N - 2; i >= 0; i--){
      mn[i] = min(mn[i * 2 + 1], mn[i * 2 + 2]);
      mx[i] = max(mx[i * 2 + 1], mx[i * 2 + 2]);
    }
    lazy = vector<int>(N * 2 - 1, 0);
  }
  void eval(int i){
    if (i < N - 1){
      lazy[i * 2 + 1] += lazy[i];
      lazy[i * 2 + 2] += lazy[i];
    }
    mn[i] += lazy[i];
    mx[i] += lazy[i];
    lazy[i] = 0;
  }
  void range_add(int L, int R, int x, int i, int l, int r){
    eval(i);
    if (r <= L || R <= l){
      return;
    } else if (L <= l && r <= R){
      lazy[i] += x;
      eval(i);
    } else {
      int m = (l + r) / 2;
      range_add(L, R, x, i * 2 + 1, l, m);
      range_add(L, R, x, i * 2 + 2, m, r);
      mn[i] = min(mn[i * 2 + 1], mn[i * 2 + 2]);
      mx[i] = max(mx[i * 2 + 1], mx[i * 2 + 2]);
    }
  }
  void range_add(int L, int R, int x){
    range_add(L, R, x, 0, 0, N);
  }
  int all_min(){
    eval(0);
    return mn[0];
  }
  int all_max(){
    eval(0);
    return mx[0];
  }
};
int main(){
  int N;
  cin >> N;
  lazy_segment_tree ST(N);
  for (int i = 0; i < N; i++){
    int R, S;
    cin >> R >> S;
    if (S == 1){
      ST.range_add(0, R, 1);
    }
    if (S == 2){
      ST.range_add(0, R, -1);
    }
    if (ST.all_max(0, N) <= 0){
      cout << '<' << endl;
    } else if (ST.all_min(0, N) >= 0){
      cout << '>' << endl;
    } else {
      cout << '?' << endl;
    }
  }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:73:24: error: no matching function for call to 'lazy_segment_tree::all_max(int, int&)'
   73 |     if (ST.all_max(0, N) <= 0){
      |                        ^
stones.cpp:55:7: note: candidate: 'int lazy_segment_tree::all_max()'
   55 |   int all_max(){
      |       ^~~~~~~
stones.cpp:55:7: note:   candidate expects 0 arguments, 2 provided
stones.cpp:75:31: error: no matching function for call to 'lazy_segment_tree::all_min(int, int&)'
   75 |     } else if (ST.all_min(0, N) >= 0){
      |                               ^
stones.cpp:51:7: note: candidate: 'int lazy_segment_tree::all_min()'
   51 |   int all_min(){
      |       ^~~~~~~
stones.cpp:51:7: note:   candidate expects 0 arguments, 2 provided