Advertisement
Guest User

Untitled

a guest
Oct 31st, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve()
  5. {
  6. int n;
  7. cin >> n;
  8. int a[n][n];
  9. for(int i=0;i<n;i++)
  10. {
  11. for(int j=0;j<n;j++)
  12. {
  13. cin >> a[i][j];
  14. }
  15. }
  16. for(int i=0;i<n-1;i++)
  17. {
  18. for(int j=0;j<n-1;j++)
  19. {
  20. if(a[i][j]==1 and a[i+1][j]==0 and a[i][j+1]==0)
  21. {
  22. cout << "NO\n";
  23. return;
  24. }
  25. }
  26. }
  27. cout << "YES\n";
  28. }
  29. int main()
  30. {
  31. ios_base::sync_with_stdio(false);
  32. cin.tie(NULL);
  33. int t;
  34. cin >> t;
  35. while(t--)
  36. {
  37. solve();
  38. }
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement