122932024-12-11 13:19:45kkOil Fieldcpp17Wrong answer 0/1001.087s2768 KiB
// 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;
	}
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms508 KiB
2Accepted1ms320 KiB
subtask20/50
3Wrong answer34ms320 KiB
4Wrong answer46ms320 KiB
5Wrong answer105ms320 KiB
6Wrong answer104ms320 KiB
7Wrong answer8ms320 KiB
subtask30/50
8Wrong answer35ms320 KiB
9Wrong answer104ms320 KiB
10Wrong answer597ms320 KiB
11Time limit exceeded1.082s464 KiB
12Time limit exceeded1.087s568 KiB
13Time limit exceeded1.046s1080 KiB
14Time limit exceeded1.085s1876 KiB
15Time limit exceeded1.085s2616 KiB
16Time limit exceeded1.083s2768 KiB
17Wrong answer8ms320 KiB