// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int main() {
int t; cin >> t;
while(t--){
int n,m; cin >> n >> m;
vector<vector<int>> tomb;
tomb.assign(n,vector<int>(m,0));
bool elso=true,jel=false,jko=false;
int el=0, utolso=0,ko=0;
for(int i=0;i<n;i++){
string val; cin >> val;
jel=false;
for(int j=0;j<m;j++){
if(val[j]=='1'){
jko=true;
tomb[i][j]=1;
if(elso){
jel=true;
el=j+1;
cerr << "AHA ";
elso=false;
}
if(jel) utolso=j+1;
ko=i;
}
cerr << tomb[i][j] << " ";
}
cerr << endl;
}
cerr << el << " " << utolso << " " << ko << endl;
elso=true;
jel=false;
int masel=el,masutolso=utolso;
for(int j=0;j<m;j++){
if(tomb[ko][j]==1){
if(elso){
elso=false;
jel=true;
masel=j+1;
}
if(jel){
masutolso=j+1;
}
}
else jel=false;
}
if(masel==el && masutolso==utolso && jko==true){
cout << 1;
}
else cout << 0;
cout << endl;
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 508 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 0/50 | ||||||
3 | Wrong answer | 34ms | 320 KiB | ||||
4 | Wrong answer | 46ms | 320 KiB | ||||
5 | Wrong answer | 105ms | 320 KiB | ||||
6 | Wrong answer | 104ms | 320 KiB | ||||
7 | Wrong answer | 8ms | 320 KiB | ||||
subtask3 | 0/50 | ||||||
8 | Wrong answer | 35ms | 320 KiB | ||||
9 | Wrong answer | 104ms | 320 KiB | ||||
10 | Wrong answer | 597ms | 320 KiB | ||||
11 | Time limit exceeded | 1.082s | 464 KiB | ||||
12 | Time limit exceeded | 1.087s | 568 KiB | ||||
13 | Time limit exceeded | 1.046s | 1080 KiB | ||||
14 | Time limit exceeded | 1.085s | 1876 KiB | ||||
15 | Time limit exceeded | 1.085s | 2616 KiB | ||||
16 | Time limit exceeded | 1.083s | 2768 KiB | ||||
17 | Wrong answer | 8ms | 320 KiB |