Saleh127

CF 1375B

Jul 4th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 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[500][500];
  7. int main()
  8. {
  9. fellow_junior
  10. test
  11. {
  12. ll r,c,d=0,e,f,i,j,k,l;
  13. cin>>r>>c;
  14. for(i=0;i<r;i++)
  15. {
  16. for(j=0;j<c;j++)
  17. {
  18. cin>>a[i][j];
  19. }
  20. }
  21. for(i=0;i<r;i++)
  22. {
  23. for(j=0;j<c;j++)
  24. {
  25. l=4;
  26. if(i==0) l--;
  27. if(i==r-1) l--;
  28. if(j==0) l--;
  29. if(j==c-1) l--;
  30. if(a[i][j]>l) d=1;
  31. a[i][j]=l;
  32. }
  33. }
  34. if(d) cout<<"NO"<<endl;
  35. else
  36. {
  37. cout<<"YES"<<endl;
  38. for(i=0;i<r;i++)
  39. {
  40. for(j=0;j<c;j++)
  41. {
  42. cout<<a[i][j]<<" ";
  43. }
  44. cout<<endl;
  45. }
  46. }
  47. }
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment