Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created December 6, 2014 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/f7c761540ad0c83045dc to your computer and use it in GitHub Desktop.
Save ik11235/f7c761540ad0c83045dc to your computer and use it in GitHub Desktop.
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[m],b[m];
for(int i=0;i<m;i++)
{
cin>>a[i]>>b[i];
a[i]--;
b[i]--;
}
for(int i=0;i<n;i++)
{
bool flend[2][n];
memset(flend,false,sizeof(flend));
for(int j=0;j<m;j++)
{
if(a[j]==i||b[j]==i)
flend[0][a[j]]=flend[0][b[j]]=true;
}
for(int j=0;j<m;j++)
{
if(flend[0][a[j]]||flend[0][b[j]])
flend[1][a[j]]=flend[1][b[j]]=true;
}
for(int j=0;j<m;j++)
{
if(a[j]==i||b[j]==i)
flend[1][a[j]]=flend[1][b[j]]=false;
}
int cnt=0;
for(int j=0;j<n;j++)
{
if(flend[1][j])
{
cnt++;
}
}
cout<<cnt<<endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment