Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //thanks God For Every Thing!
- //contest link:
- #include<bits/stdc++.h>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <cstdlib>
- #define pi (acos(-1.0)) //3.1415926535897932384626
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n');
- #define fasterio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- #define NL printf("\n")
- #define fin freopen("int.txt","r",stdin);
- #define fout freopen("out.txt","w",stdout);
- using namespace std;
- typedef long long int ll;
- typedef double dl;
- typedef unsigned long long ul;
- // ----------------------Pre made Functions---------------------------//
- template <class T> T gcd(T a, T b){if(a == 0) return b;return gcd(b%a, a);}
- template <class T> T lcm(T a, T b){return ((a*b)/gcd(a, b));}
- // ----------------------Slove---------------------------//
- bool one_row(int arra[100][100]);
- bool all_one(int arra[100][100]);
- bool cal_one(int arra[100][100]);
- bool cal_zero(int arra[100][100]);
- int n, m, i, j;
- int arra[100][100];
- int main()
- {
- int ans=0;
- while(scanf("%d %d", &n, &m)!=EOF)
- {
- int c=0;
- if(n==0 && m==0)
- break;
- else
- {
- for(i=0; i<n; i++)
- {
- for(j=0; j<m; j++)
- {
- cin>>arra[i][j];
- }
- }
- if(one_row(arra))
- c++;
- if(all_one(arra))
- c++;
- if(cal_one(arra))
- c++;
- if(cal_zero(arra))
- c++;
- cout<<c<<endl;
- }
- }
- return 0;
- }
- bool one_row(int arra[100][100]) //find at least one 1 in every row;
- {
- int cnt=0;
- for(i=0; i<n; i++)
- {
- int l=0;
- for(j=0; j<m; j++)
- {
- if(arra[i][j]!=0)
- l++;
- }
- if(l>0)
- cnt++;
- }
- if(cnt==n)
- return true;
- else
- return false;
- }
- bool all_one(int arra[100][100]) //check every row has at least one zero;
- {
- int cnt=0;
- for(i=0; i<n; i++)
- {
- int l=0;
- for(j=0; j<m; j++)
- {
- if(arra[i][j]!=1)
- l++;
- }
- if(l>0)
- cnt++;
- }
- if(cnt==n)
- return true;
- else
- return false;
- }
- bool cal_one(int arra[100][100]) //check every cllum has at least one 1;
- {
- int cnt=0;
- for(i=0; i<m; i++)
- {
- int l=0;
- for(j=0; j<n; j++)
- {
- if(arra[j][i]!=0)
- l++;
- }
- if(l>0)
- cnt++;
- }
- if(cnt==m)
- return true;
- else
- return false;
- }
- bool cal_zero(int arra[100][100]) //check every cllum has at least one 0;
- {
- int cnt=0;
- for(i=0; i<m; i++)
- {
- int l=0;
- for(j=0; j<n; j++)
- {
- if(arra[j][i]!=1)
- l++;
- }
- if(l>0)
- cnt++;
- }
- if(cnt==m)
- return true;
- else
- return false;
- }
- //author: ANIKAKSH;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement