-
Notifications
You must be signed in to change notification settings - Fork 0
/
NyanCatCrisis.cpp
47 lines (46 loc) · 1.06 KB
/
NyanCatCrisis.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
45
46
47
#include <bits/stdc++.h>
using namespace std;
int t, n, r, k, tmp;
bool dis(pair<int, int> a, pair<int, int> b)
{
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second) <= r * r;
}
int dfs(vector<pair<int, int>> &arr, vector<bool> &visit, int num)
{
int size = 1;
visit[num] = true;
for (int i = 0; i < n; i++)
{
if (!visit[i] && dis(arr[i], arr[num]))
{
size += dfs(arr, visit, i);
}
}
return size;
}
int main()
{
cin >> t;
while (t--)
{
int ans1 = 0, ans2 = 0;
cin >> n >> r >> k;
vector<pair<int, int>> arr(n);
vector<bool> visit(n, false);
for (int i = 0; i < n; i++)
{
cin >> arr[i].first >> arr[i].second;
}
for (int i = 0; i < n; i++)
{
if (!visit[i])
{
if (dfs(arr, visit, i) >= k)
ans2++;
else
ans1++;
}
}
cout << ans1 << " " << ans2 << endl;
}
}