This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define MAXN 300007
using namespace std;
int n,m,br[25],curr;
int a[MAXN],s[MAXN][25],res,ans;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int f=1;f<=m;f++){
cin>>s[i][f];
a[i]*=2; a[i]+=s[i][f];
br[f]+=s[i][f];
}
}
for(int i=1;i<=n;i++){
for(int f=1;f<=m;f++)br[f]-=s[i][f];
curr=res=0;
for(int f=1;f<=m;f++){
curr*=2;
if(br[f]==n/2)curr++;
if(br[f]>=n/2)res++;
}
ans=0;
for(int f=1;f<=n;f++){
if(f!=i)ans=max(ans,res-__builtin_popcount(curr&a[f]));
}
cout<<ans<<"\n";
for(int f=1;f<=m;f++)br[f]+=s[i][f];
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |