-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (38 loc) · 859 Bytes
/
main.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
#include <bits/stdc++.h>
using namespace std;
vector< vector<int> > tab(100005, vector<int>());
bool vis[100005];
void dfs(int n, int pop){
vis[n] = 1;
for(int i = 0; i < tab[n].size(); i++){
if(tab[n][i] != pop && vis[tab[n][i]]){
cout << "NIE\n";
exit(0);
}
else if(tab[n][i] != pop)
dfs(tab[n][i], n);
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int v, e; cin >> v >> e;
if(v-1 != e){
cout << "NIE\n";
exit(0);
}
int a, b;
for(int i = 0; i < e; i++){
cin >> a >> b; a--, b--;
tab[a].push_back(b);
tab[b].push_back(a);
}
dfs(0, -1);
for(int i = 0; i < v; i++)
if(!vis[i]){
cout << "NIE\n";
exit(0);
}
cout << "TAK\n";
return 0;
}