-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABCDE.cpp
More file actions
71 lines (57 loc) · 759 Bytes
/
ABCDE.cpp
File metadata and controls
71 lines (57 loc) · 759 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
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <vector>
using namespace std;
int n, m;
vector<int> con[2000];
bool visited[2000];
void input()
{
cin >> n >> m;
while (m--)
{
int a, b;
cin >> a >> b;
con[a].push_back(b);
con[b].push_back(a);
}
}
void dfs(int k, int cnt)
{
if (cnt == 5)
{
cout << 1;
exit(0);
}
for (int i = 0; i < con[k].size(); i++)
{
int next = con[k][i];
if (visited[next])
continue;
visited[next] = 1;
dfs(next, cnt + 1);
visited[next] = 0;
}
}
void solution()
{
for (int i = 0; i < n; i++)
{
visited[i] = 1;
dfs(i, 1);
visited[i] = 0;
}
cout << 0;
}
void solve()
{
input();
solution();
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
solve();
return 0;
}