Submission #562780

# Submission time Handle Problem Language Result Execution time Memory
562780 2022-05-15T09:51:39 Z SSRS Sterilizing Spray (JOI15_sterilizing) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
struct binary_indexed_tree{
  int N;
  vector<int> BIT;
  binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
  }
  void add(int i, int x){
    i++;
    while (i <= N){
      BIT[i] += x;
      i += i & -i;
    }
  }
  int sum(int i){
    int ans = 0;
    while (i > 0){
      ans += BIT[i];
      i -= i & -i;
    }
    return ans;
  }
  int sum(int L, int R){
    return sum(R) - sum(L);
  }
};
int main(){
  int N, Q, K;
  cin >> N >> Q >> K;
  vector<int> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  set<int> st;
  binary_indexed_tree BIT;
  for (int i = 0; i < N; i++){
    if (C[i] == 1){
      st.insert(i);
      BIT.add(i, 1);
    }
  }
  for (int i = 0; i < Q; i++){
    int S, T, U;
    cin >> S >> T >> U;
    if (S == 1){
      T--;
      BIT.add(T, -C[T]);
      C[T] = U;
      BIT.add(T, U);
      if (U == 0){
        st.erase(T);
      } else {
        st.insert(T);
      }
    }
    if (S == 2){
      T--;
      if (K >= 2){
        while (true){
          auto itr = st.lower_bound(T);
          if (itr == st.end()){
            break;
          }
          if (*itr >= U){
            break;
          }
          C[*itr] = 0;
          BIT.add(*itr, -1);
          st.erase(itr);
        }
      }
    }
    if (S == 3){
      T--;
      cout << BIT.sum(T, U) << endl;
    }
  }
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:35:23: error: no matching function for call to 'binary_indexed_tree::binary_indexed_tree()'
   35 |   binary_indexed_tree BIT;
      |                       ^~~
sterilizing.cpp:6:3: note: candidate: 'binary_indexed_tree::binary_indexed_tree(int)'
    6 |   binary_indexed_tree(int N): N(N), BIT(N + 1, 0){
      |   ^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:6:3: note:   candidate expects 1 argument, 0 provided
sterilizing.cpp:3:8: note: candidate: 'binary_indexed_tree::binary_indexed_tree(const binary_indexed_tree&)'
    3 | struct binary_indexed_tree{
      |        ^~~~~~~~~~~~~~~~~~~
sterilizing.cpp:3:8: note:   candidate expects 1 argument, 0 provided
sterilizing.cpp:3:8: note: candidate: 'binary_indexed_tree::binary_indexed_tree(binary_indexed_tree&&)'
sterilizing.cpp:3:8: note:   candidate expects 1 argument, 0 provided