Advertisement
Saleh127

CF 1421B

Oct 18th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. test
  11. {
  12. ll n,c,d,e,f,i,j,k,l;
  13. char a[205][205];
  14. cin>>n;
  15. for(i=1;i<=n;i++)
  16. {
  17. for(j=1;j<=n;j++)
  18. {
  19. cin>>a[i][j];
  20. }
  21. }
  22. if(a[1][2]==a[2][1] && a[n-1][n]==a[n][n-1] && a[1][2]!=a[n][n-1])
  23. {
  24. cout<<0<<endl;
  25. }
  26. else if(a[1][2]==a[2][1] && a[n-1][n]==a[n][n-1] && a[1][2]==a[n][n-1])
  27. {
  28. cout<<2<<endl;
  29. cout<<"1 2\n2 1"<<endl;
  30. }
  31. else if(a[1][2]==a[2][1] && a[n-1][n]!=a[n][n-1])
  32. {
  33. if(a[1][2]==a[n-1][n])
  34. {
  35. cout<<"1\n"<<n-1<<" "<<n<<endl;
  36. }
  37. else cout<<"1\n"<<n<<" "<<n-1<<endl;
  38. }
  39. else if(a[1][2]!=a[2][1] && a[n-1][n]==a[n][n-1])
  40. {
  41. if(a[1][2]==a[n-1][n])
  42. {
  43. cout<<"1\n1 2"<<endl;
  44. }
  45. else cout<<"1\n2 1"<<endl;
  46. }
  47. else if(a[1][2]!=a[2][1] && a[n-1][n]!=a[n][n-1])
  48. {
  49. if(a[1][2]==a[n-1][n])
  50. {
  51. cout<<"2\n1 2\n"<<n<<" "<<n-1<<endl;
  52. }
  53. else cout<<"2\n1 2\n"<<n-1<<" "<<n<<endl;
  54. }
  55. }
  56.  
  57.  
  58. return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement