-
Notifications
You must be signed in to change notification settings - Fork 0
/
2412.cpp
60 lines (47 loc) · 872 Bytes
/
2412.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
48
49
50
51
52
53
54
55
56
57
58
59
60
//2412
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> graph[], bool visited[], int u)
{
visited[u] = true;
for(int j = 0; j < (int)graph[u].size(); j++)
{
int v = graph[u][j];
if(!visited[v])
dfs(graph, visited, v);
}
}
int main()
{
int arvore, alcance;
cin >> arvore >> alcance;
int x[arvore], y[arvore];
for(int i = 0; i < arvore; i++)
cin >> x[i] >> y[i];
vector<int> graph[arvore];
for(int u = 0; u < arvore; u++)
{
for(int v = 0; v < arvore; v++)
{
if(u != v && hypot(x[v]-x[u], y[v]-y[u]) <= alcance)
{
graph[u].push_back(v);
graph[v].push_back(u);
}
}
}
bool visited[1002] = {};
bool consegue = true;
dfs(graph, visited, 0);
for(int i = 0; i < arvore; i++)
{
if(!visited[i])
{
printf("N\n");
consegue = false;
break;
}
}
if(consegue)
printf("S\n");
}