Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void solve()
- {
- int n;
- cin >> n;
- int a[n][n];
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- cin >> a[i][j];
- }
- }
- for(int i=0;i<n-1;i++)
- {
- for(int j=0;j<n-1;j++)
- {
- if(a[i][j]==1 and a[i+1][j]==0 and a[i][j+1]==0)
- {
- cout << "NO\n";
- return;
- }
- }
- }
- cout << "YES\n";
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin >> t;
- while(t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement