Created
December 6, 2014 17:24
-
-
Save ik11235/f7c761540ad0c83045dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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