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 F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=3e5+5;
int a[N],n,m,f[20];
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for (int i=1;i<=n;i++){
for (int j=0;j<m;j++){
bool x;cin>>x;
if (x) a[i]|=(1<<j),f[j]++;
}
}
for (int i=1;i<=n;i++){
for (int j=0;j<m;j++) if (a[i]&(1<<j)) f[j]--;
int ans=0;
for (int j=1;j<=n;j++){
if (j==i) continue;
for (int k=0;k<m;k++) if (a[j]&(1<<k)) f[k]--;
int x=0;
for (int k=0;k<m;k++) if (f[k]>=n/2) x++;
for (int k=0;k<m;k++) if (a[j]&(1<<k)) f[k]++;
ans=max(ans,x);
}
for (int k=0;k<m;k++) if (a[i]&(1<<k)) f[k]++;
cout<<ans<<endl;
}
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... |