-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwheresmyinternet.cpp
70 lines (65 loc) · 1.1 KB
/
wheresmyinternet.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
61
62
63
64
65
66
67
68
69
70
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <ctype.h>
#include <queue>
#include <map>
#include <set>
#include <unordered_set>
#define EPSILON 0.00001
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ull i, j, k;
deque<int> q = { 0 };
int size, edges, src, dest, top;
bool outPut = false;
cin >> size >> edges;
vector<bool> seen(size, false);
seen[0] = true;
vector<vector<int>> adj(size);
for (i = 0; i < edges; i++)
{
cin >> src >> dest;
adj[src-1].push_back(dest-1);
adj[dest-1].push_back(src-1);
}
while (q.size())
{
top = q.front();
q.pop_front();
for (auto item : adj[top])
{
if (!seen[item])
{
seen[item] = true;
q.push_back(item);
}
}
}
for(i = 0; i < size; i++)
{
if (!seen[i])
{
outPut = true;
cout << i + 1 << "\n";
}
}
if (!outPut)
{
cout << "Connected\n";
}
return 0;
}