Accepted
/in/foo.cc: In function 'int main()': /in/foo.cc:14:10: warning: unused variable 'k' [-Wunused-variable] int i,j,k,x,y; ^
代码
#include<iostream>
using namespace std;
int f[105][105],n,m;
void floyed()
{
int i,j,k;
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(f[i][k]&&f[k][j])f[i][j]=1;
}
int main()
{
int i,j,k,x,y;
cin>>n>>m;
for(i=1;i<=m;i++)
{
cin>>x>>y;
f[x][y]=1;
}
floyed();
int ans=0,num=0;
for(i=1;i<=n;i++)
{
num=0;
for(j=1;j<=n;j++)
{
if(f[i][j])num++;
}
if(num>=(n+1)/2)ans++;
num=0;
for(j=1;j<=n;j++)
{
if(f[j][i])num++;
}
if(num>=(n+1)/2)ans++;
}
cout<<ans;
}