Advertisement
a53

ccmax

a53
Feb 25th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream fin("ccmax.in");
  4. ofstream fout("ccmax.out");
  5.  
  6. int n,A[101][101],P[101];
  7.  
  8. void DF(int v,int c)
  9. {
  10. P[v]=c;
  11. for(int i=1;i<=n;i++)
  12. if(A[v][i]==1 && P[i]==0)
  13. DF(i,c);
  14. }
  15. int main()
  16. {
  17. int x,y;
  18. int max=0,ap=0,F[101]={0};
  19. fin>>n;
  20. while(fin>>x>>y)
  21. A[x][y]=A[y][x]=1;
  22. int c=0;
  23. for(int i=1;i<=n;i++)
  24. if(P[i]==0)
  25. {
  26. c++;
  27. DF(i,c);
  28. }
  29. for(int i=1;i<=n;i++)
  30. F[P[i]]++;
  31. for(int i=1;i<=c;i++)
  32. if(F[i]>max) { max=F[i]; ap=1; }
  33. else if(F[i]==max) ap++;
  34. fout<<max<<" "<<ap;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement