Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool a[105][105],viz[105];
- int n,st[105];
- void citire()
- {
- int m,x,y;
- cin>>n>>m;
- for (int i=1;i<=m;i++)
- {
- cin>>x>>y;
- a[x][y]=1;
- }
- }
- void bck(int k)
- {
- for (int i=1;i<=n;i++)
- {
- st[k]=i;
- if (a[st[k-1]][i] || a[i][st[k-1]])
- if (k==3)
- {
- if (a[st[3]][st[1]] || a[st[1]][st[3]])
- cout<<st[1]<<' '<<st[2]<<' '<<st[3]<<'\n';
- }
- else
- bck(k+1);
- }
- }
- int main()
- {
- citire();
- for (int i=1;i<=n;i++)
- {
- st[1]=i;
- bck(2);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement