Saleh127

cf 1207B

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