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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std ;
const int N = 3e5 ;
int n, m, a[N + 1], kol[20], num[(1 << 20)], cnt[(1 << 20)] ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n >> m ;
for(int i = 0 ; i < (1 << m) ; i++)
for(int j = 0 ; j < m ; j++)
if((1 << j) & i)
num[i]++ ;
for(int i = 1 ; i <= n ; i++)
{
for(int j = 0 ; j < m ; j++)
{
bool c ;
cin >> c ;
if(c)
{
kol[j]++ ;
a[i] ^= (1 << j) ;
}
}
cnt[a[i]]++ ;
}
for(int i = 1 ; i <= n ; i++)
{
int ans = 0, now = 0, abu = 0 ;
for(int j = 0 ; j < m ; j++)
{
if((1 << j) & a[i])
kol[j]-- ;
if((n - 2) / 2 < kol[j])
{
now++ ;
if((n - 2) / 2 == kol[j] - 1)
abu ^= (1 << j) ;
}
}
cnt[a[i]]-- ;
for(int j = 0 ; j < (1 << m) ; j++)
{
if(!cnt[j])
continue ;
//(abu & j) - 0101010 кол-во единиц будет означать на сколько ухудшился ответ
ans = max(ans, now - num[(abu & j)]) ;
}
cnt[a[i]]++ ;
for(int j = 0 ; j < m ; j++)
if((1 << j) & a[i])
kol[j]++ ;
cout << ans << '\n' ;
}
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... |