Advertisement
add1ctus

Озборување

Apr 14th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     bool znae[101][101]; //znae[a][b] е true ако а гу знае аферу на b
  10.     memset(znae,false,101*101);
  11.     for(int i=0;i<101;i++)
  12.         znae[i][i]=true;
  13.  
  14.     int n,m;
  15.     cin>>n>>m;
  16.  
  17.     for(int i=0;i<m;i++)
  18.     {
  19.         int a,b;
  20.         cin>>a>>b;
  21.         for(int j=0;j<=n;j++)
  22.             if(znae[a][j])
  23.                 znae[b][j]=true;
  24.             else if(znae[b][j])
  25.                 znae[a][j]=true;
  26.     }
  27.  
  28.     int najvekeTajni=0,brojac;
  29.  
  30.     for(int i=0;i<=n;i++)
  31.     {
  32.         brojac=0;
  33.         for(int j=0;j<=n;j++)
  34.             if(znae[i][j])
  35.                 brojac++;
  36.         najvekeTajni=max(najvekeTajni,brojac);
  37.     }
  38.  
  39.     cout<<najvekeTajni-1;
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement