-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB103.cpp
More file actions
61 lines (49 loc) · 764 Bytes
/
Copy pathB103.cpp
File metadata and controls
61 lines (49 loc) · 764 Bytes
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
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
using namespace std;
vector<int> adj[102];
vector<bool> visited(102, 0);
void dfs(int u)
{
for(int v : adj[u])
{
if(!visited[v])
{
visited[v] = true;
dfs(v);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, m; cin >> n >> m;
for(int i = 0; i < m; i++)
{
int u, v; cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
bool ok = true;
int count= 0;
if(n != m) ok = 0;
for(int i = 1; i < n+1; i++)
{
if(!ok) break;
if(!visited[i])
{
visited[i] = true;
dfs(i);
count++;
}
if(count > 1)
{
ok = 0; break;
}
}
cout << (ok ? "FHTAGN!" : "NO") << '\n';
return 0;
}