-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriverKDTree.cpp
44 lines (44 loc) · 1.05 KB
/
driverKDTree.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// #include "rangeTree.h"
#include "kdTree.h"
using namespace project;
using namespace std;
#include <bits/stdc++.h>
int main()
{
int n, m;
cin >> n;
vector<data> p;
for(int i = 0; i < n; i++){
double x, y;
cin >> x >> y;
p.push_back(data(x, y, i));
}
kdTree tree(p, 1);
// printf("here\n");
cin >> m;
int m1 = m;
map<pair<double, double>, bool> vis;
vector<vector<double>> queries;
while(m--){
double u1, u2, v1, v2;
cin >> u1 >> v1 >> u2 >> v2;
queries.push_back({u1,v1,u2,v2});
// std::vector<data> v = tree.query(tree.root,{u1,u2},{v2, v1});
// for (int i = 0; i < v.size(); ++i)
// {
// vis[{v[i].x, v[i].y}] = 1;
// // printf("%f %f \n",v[i].x, v[i].y );
// }
int ans= tree.queryCnt(tree.root,{u1,u2},{v2, v1});
printf("%d\n",ans );
}
// cout<<n<<endl;
// for(int i = 0; i < n; i++){
// cout<<p[i].x<<" "<<p[i].y<<" "<<vis[{p[i].x, p[i].y}]<<endl;
// }
// cout<<m1<<endl;
// for(int i = 0; i < m1; i++){
// cout<<queries[i][0]<<" "<<queries[i][1]<<" "<<queries[i][2]<<" "<<queries[i][3]<<endl;
// }
return 0;
}