为什么存单向边判双相就过了,但存双向边判单项就做了,关键还都是一。
过了,但还是想不出来。
code
#include<bits/stdc++.h>
using namespace std;
int f[101], s[101], ans, n, m;
bool vis[101][101];
int main(){
cin >> n >> m;
for(int i = 1; i <= m; ++i){
int x, y;
cin >> x >> y;
vis[x][y] = vis[y][x] = true;
}
for(int k = 1; k <= n; ++k)
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
vis[i][j] = vis[i][j] | vis[i][k] & vis[k][j];
for(int i = 1; i <= n; ++i){
int t = 0;
for(int j = 1; j <= n; ++j)
if(vis[i][j])
t++;
if(t == n)
ans++;
}
cout << ans;
return 0;
}