Language: C++

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

class Node {
public:
  int location
  int parent;
  int right;
  int left;

  Node() {}
};

class Point {
public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y)
    : id(id)
    , x(x)
    , y(y)
    {}

  bool operator < (const Point& p) const {
    return id < p.id;
  }

  void print() {
    cout << id << endl;
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];

int np;

bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }
bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }

int makeKDTree(int left, int right, int depth) {
  if (!(left < right)) {
    return NIL;
  }
  int mid = (left + right) / 2;
  int t = np++;
  if (depth % 2 == 0) {
    sort(P + left, P + right, lessX);
  } else {
    sort(P + left, P + right, lessY);
  }
  T[t].location = mid;
  T[t].left = makeKDTree(left, mid, depth + 1);
  T[t].right = makeKDTree(mid + 1, right, depth + 1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if (sx <= x && x <== tx && sy <= y && y <= ty) {
    ans.push_back(P[T[v]].location);
  }

  if (depth % 2 == 0) {
    if (T[v].left != NIL) {
      if (sx <= x) {
        find(T[v].left, sx, tx, sy, ty, depth + 1, ans);
      }
    }
    if (T[v].right != NIL) {
      if (x <= tx) {
        find(T[v].right, sx, tx, sy, ty, depth + 1, ans);
      }
    }
  } else {
    if (T[v].left != NIL) {
      if (sy <= y) {
        find(T[v].left, sx, tx, sy, ty, depth + 1, ans);
      }
    }
    if (T[v].right != NIL) {
      if (y <= ty) {
        find(T[v].right, sx, tx, sy, ty, depth + 1, ans);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x, y;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    P[i] = Point(i, x, y);
    T[i].left = T[i].right = T[i].parent = NIL;
  }

  np = 0;

  int root = makeKDTree(0, N, 0);

  int q;
  cin >> q;
  int sx, tx, sy, ty;
  vector<int> ans;
  for (int i = 0; i < q; i++) {
    cin >> sx >> tx >> sy >> ty;
    ans.clear();
    find(root, sx, tx, sy, ty, 0, ans);
    sort(ans.begin(), ans.end());
    for (int j = 0; j < ans.size(); j++) {
      ans[j].print()
    }
    cout << endl;
  }

  return 0;
}


Compiler output:
a.cc:9:7: error: expected ';' at end of member declaration
    9 |   int location
      |       ^~~~~~~~
      |               ;
a.cc: In function 'void find(int, int, int, int, int, int, std::vector<Point>&)':
a.cc:70:22: error: expected primary-expression before '=' token
   70 |   if (sx <= x && x <== tx && sy <= y && y <= ty) {
      |                      ^
a.cc:71:20: error: no match for 'operator[]' (operand types are 'Point [1000000]' and 'Node')
   71 |     ans.push_back(P[T[v]].location);
      |                    ^
a.cc: In function 'int main()':
a.cc:122:9: error: no matching function for call to 'find(int&, int&, int&, int&, int&, int, std::vector<int>&)'
  122 |     find(root, sx, tx, sy, ty, 0, ans);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:66:6: note: candidate: 'void find(int, int, int, int, int, int, std::vector<Point>&)'
   66 | void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans) {
      |      ^~~~
a.cc:66:76: note:   no known conversion for argument 7 from 'std::vector<int>' to 'std::vector<Point>&'
   66 | void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans) {
      |                                                             ~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 7 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 7 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 7 provided
a.cc:125:14: error: request for member 'print' in 'ans.std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  125 |       ans[j].print()
      |              ^~~~~