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