Submission #889771

#TimeUsernameProblemLanguageResultExecution timeMemory
889771vjudge1Council (JOI23_council)C++17
22 / 100
4078 ms28556 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; signed main(){ ios_base::sync_with_stdio(); cin.tie(0); int n,m; cin>>n>>m; int a[n][m]; map <int,int> mp; vector <int> v; for(int i=0;i<n;i++){ int x=0; for(int j=0;j<m;j++){ cin>>a[i][j]; if(a[i][j]==1)x+=(1<<j); } v.pb(x); mp[x]++; } vector <int> cnt,cnt2((1<<m)); for(int i=0;i<m;i++){ int kol=0; for(int j=0;j<n;j++){ if(a[j][i]==1)kol++; } cnt.pb(kol); } for(int i=0;i<(1<<m);i++){ for(int j=0;j<m;j++){ if((i & (1<<j))!=0)cnt2[i]++; } } if(n<=3000){ for(int i=0;i<n;i++){ for(int k=0;k<m;k++){ if(a[i][k]==1)cnt[k]--; } int mx=0; for(int j=0;j<n;j++){ if(i!=j){ int kol=0; for(int k=0;k<m;k++){ if(a[j][k]==1)cnt[k]--; } for(int k=0;k<m;k++){ if(cnt[k]>=n/2)kol++; } for(int k=0;k<m;k++){ if(a[j][k]==1)cnt[k]++; } mx=max(mx,kol); } } cout<<mx<<"\n"; for(int k=0;k<m;k++){ if(a[i][k]==1)cnt[k]++; } } return 0; } for(int i=0;i<n;i++){ int mx=0,kol=0,min=0; mp[v[i]]--; for(int j=0;j<m;j++){ if(a[i][j]==1)cnt[j]--; if(cnt[j]>=n/2)kol++; if(cnt[j]==n/2)min+=(1<<j); } for(int j=0;j<(1<<m);j++){ int x=j&min; if(mp[j]!=0)mx=max(mx,kol-cnt2[x]); } mp[v[i]]++; for(int j=0;j<m;j++){ if(a[i][j]==1)cnt[j]++; } cout<<mx<<"\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...