/**
Baktiyar™
respa gold Soon.....
**/
#include <bits/stdc++.h>
using namespace std ;
#define ent '\n'
#define F first
#define S second
#define no "NO\n"
#define yes "YES\n"
#define pb push_back
#define pf push_front
#define sz(w) w.size()
#define int long long
#define all(w) w.begin() , w.end()
#define DH ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = 1e9 + 6 , MOD = 1e9 + 7 , N = 1e6 + 11 , inf = 1e9 + 111 , INF = 1e18 , LG = 20 , M = 555 ;
/**
int gcd (int a, int b) {
while (b) {
a %= b;
swap (a, b);
}
return a;
}
**/
bool comp(pair<int,int> a, pair<int,int> b){
return a.F+a.S < b.F+b.S;
}
/**int MEX(set<int>& s) {
int mex = 0;
while (s.count(mex)) {
mex++;
}
return mex;
}
**/
void accepted() {
int n , m , c = 0 , d = 0 , mn = 2555 , Mn = 2555 ;
cin >> n >> m ;
char a[n][m] , b[m][n] ;
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++) {
cin >> a[i][j] ;
b[j][i] = a[i][j] ;
}
}
for(int i = 0 ; i < n ; i++) {
for(int j = 0 ; j < m ; j++) {
if (a[i][j] == '1') {
c++;
}
}
mn = min(mn , c) ;
}
for (int i = 0 ; i < m ; i++) {
for (int j = 0 ; j < n ; j++) {
if (b[i][j] == '1') {
d++;
}
}
Mn = min(Mn , d) ;
}
cout << mn * Mn ;
}
signed main()
{
DH
//freopen( "input.in" , "r" , stdin ) ;
//freopen( "output.out" , "w" , stdout ) ;
int T = 1 ;
//cin >> T ;
while( T -- )
{
accepted() ;
cout << ent ;
}
}
/**
I❤️U
**/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |