Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int n, m, a[101][101], vis[101], ok;
- void dfs(int i) {
- vis[i] = 1;
- for (int j = 1; j <= n; j++)
- if (a[i][j]) {
- a[i][j] = a[j][i] = 0;
- if (vis[j])
- ok = 1;
- else
- dfs(j);
- }
- }
- int main() {
- cin >> n >> m;
- int x, y;
- for (int i = 1; i <= m; i++) {
- cin >> x >> y;
- a[x][y] = a[y][x] = 1;
- }
- dfs(1);
- if (ok)
- cout << "DA";
- else
- cout << "NU";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement