Submission #1086810

#TimeUsernameProblemLanguageResultExecution timeMemory
1086810coldbr3wCouncil (JOI23_council)C++14
6 / 100
4089 ms53032 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const ll N = 2e6 + 100; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll block = 350; ll n,m; ll a[N][21], res[N], cnt[N]; pll mn[N]; void to_thic_cau(){ cin >> n >> m; for(int i = 0; i < (1 << m);i++) mn[i] = {inf, inf}; for(int i = 1; i <= n;i++){ for(int j = 0; j < m;j++){ cin >> a[i][j]; if(a[i][j] == 1) cnt[j]++; } } for(int i = 1; i <= n;i++){ for(int msk = 0; msk < (1 << m);msk++){ ll cur = 0; for(int j = 0; j < m;j++) if((msk & (1 << j)) && a[i][j] == 1) cur++; if(cur < mn[msk].F) mn[msk].S = mn[msk].F, mn[msk].F = cur; else if(cur < mn[msk].S) mn[msk].S = cur; } } for(int i = 1; i <= n;i++){ ll msk = 0, cur = 0, res = 0; for(int j = 0; j < m;j++){ if(a[i][j] == 1) cnt[j]--; if(cnt[j] == n / 2) msk |= (1 << j), res++; else if(cnt[j] > n / 2) res++; } for(int j = 0; j < m;j++) if((msk & (1 << j)) && a[i][j] == 1) cur++; if(cur == mn[msk].F) res -= mn[msk].S; else res -= mn[msk].F; for(int j = 0; j < m;j++) if(a[i][j] == 1) cnt[j]++; cout << res << "\n"; assert(res >= 0); } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); ll tc = 1; //cin >> tc; while(tc--) to_thic_cau(); }
#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...