Skip to content

Commit

Permalink
1360E
Browse files Browse the repository at this point in the history
  • Loading branch information
userr2232 committed Oct 12, 2021
1 parent c4b364c commit f65aa68
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Codeforces/E/1360.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <vector>
using namespace std;

int main() {
int TC; cin >> TC;
while(TC--) {
int n; cin >> n;
vector<string> M(n);
for(auto& str : M) cin >> str;
bool NO = false;
for(int i = 0; i < n && !NO; ++i) for(int j = 0; j < n && !NO; ++j) {
char c = M[i][j];
if(c == '1') {
if(i == n-1 || j == n-1) continue;
if(i < n-1 && M[i+1][j] == '1') continue;
if(j < n-1 && M[i][j+1] == '1') continue;
cout << "NO\n";
NO = true;
}
}
if(!NO) cout << "YES\n";
}
return 0;
}

0 comments on commit f65aa68

Please sign in to comment.