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