Submission #1005095

#TimeUsernameProblemLanguageResultExecution timeMemory
1005095pccCouncil (JOI23_council)C++17
40 / 100
4057 ms12404 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> const int mxn = 3e5+10; const int B = 15; int arr[mxn]; int dp[1<<B]; int N,M; int cnt[mxn]; int f(int id){ for(int i = 0;i<M;i++){ if((1<<i)&arr[id])cnt[i]--; } dp[arr[id]]--; int mask = 0,ans = 0; for(int i = 0;i<M;i++){ if(cnt[i] == N/2)mask|=1<<i; if(cnt[i] >= N/2)ans++; } int c = B; for(int i = 0;i<(1<<M);i++)if(dp[i])c = min(c,__builtin_popcount(mask&i)); ans -= c; for(int i = 0;i<M;i++)if((1<<i)&arr[id])cnt[i]++; dp[arr[id]]++; return ans; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>N>>M; for(int i = 1;i<=N;i++){ for(int j = 0;j<M;j++){ int k; cin>>k; if(k)cnt[j]++,arr[i]|=1<<j; } dp[arr[i]]++; } for(int i = 1;i<=N;i++)cout<<f(i)<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...