Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. scanf("%d",&t);
  7. while(t--)
  8. {
  9. int n,m=1;
  10. scanf("%d",&n);
  11. int num[n+1][n+1];
  12. for(int i=1;i<=n;i++)
  13. {
  14. for(int j=1;j<=n;j++)
  15. {
  16. scanf("%d",&num[i][j]);
  17. }
  18. }
  19. /*for(int i=1;i<=n;i++){
  20. for(int j=1;j<=n;j++){
  21. cout<<num[i][j]<<" ";
  22. }cout<<endl;}*/
  23. m=0;
  24. for(int i=1;i<=n;i++)
  25. {
  26. for(int j=2;j<=n;j++)
  27. {
  28. if(num[j][i]==num[i][j] && (num[j][i] !=0 && num[i][j]!=0))
  29. {
  30. num[j][i]=0;
  31. m++;
  32. }
  33. }
  34.  
  35. }
  36. cout<<m<<endl;
  37. for(int i=1;i<=n;i++)
  38. {
  39. for(int j=1;j<=n;j++)
  40. {
  41. if(num[i][j]==num[i][j+1])
  42. {
  43. m++;
  44. }
  45. }
  46. }
  47. cout<<m<<endl;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement