强连通<=>每两个点之间一定可达
Floyd暴力处理,然后判断可达即可
/**
*
* ━━━━━━神兽出没━━━━━━
* ┏┓ ┏┓
* ┏┛┻━━━┛┻┓
* ┃ ┃
* ┃ ━ ┃
* ┃ ┳┛ ┗┳ ┃
* ┃ ┃
* ┃ ┻ ┃
* ┃ ┃
* ┗━┓ ┏━┛Code is far away from bug with the animal protecting
* ┃ ┃ 神兽保佑,代码无bug
* ┃ ┃
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*
* ━━━━━━感觉萌萌哒━━━━━━
*/
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#define MAX 0xfffffff
#define INIT(a) memset(a,0,sizeof(a))
using namespace std;
int main()
{
int g[100][100];
int n,m;
cin>>n>>m;
INIT(g);
while(m--)
{
int x,y;
cin>>x>>y;
g[x][y]=1;
}
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)
if(g[j][i]&&g[i][k])
g[j][k]=1;
int flag=0;
for(int i=0;i<n;i++)
for(int j=0;j<i;j++)
if(g[i][j]!=g[j][i])
flag=1;
if(flag==1)cout<<"no";
else cout<<"yes";
return 0;
}