Submission #1014172

#TimeUsernameProblemLanguageResultExecution timeMemory
101417212345678Council (JOI23_council)C++17
56 / 100
4051 ms34588 KiB
#include <bits/stdc++.h> using namespace std; const int nx=3e5+5, mx=20; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") int n, m, sm[mx], a[nx][mx], msk[nx], cnt[(1<<mx)+5], res[nx]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m; for (int i=1; i<=n; i++) for (int j=0; j<m; j++) cin>>a[i][j], sm[j]+=a[i][j], msk[i]+=(1-a[i][j])*(1<<j); for (int i=1; i<=n; i++) cnt[msk[i]]++; for (int i=1; i<=n; i++) { cnt[msk[i]]--; int vl=0, ans=0; for (int j=0; j<m; j++) { if (sm[j]-a[i][j]>=(n/2)) ans++; if (sm[j]-a[i][j]!=(n/2)) vl+=(1<<j); } for (int j=0; j<(1<<m); j++) if (cnt[j]) res[i]=max(res[i], ans-(m-__builtin_popcount(j|vl))); cnt[msk[i]]++; } for (int i=1; i<=n;i ++) cout<<res[i]<<'\n'; }
#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...