Submission #889718

#TimeUsernameProblemLanguageResultExecution timeMemory
889718vjudge1Council (JOI23_council)C++17
22 / 100
4035 ms36296 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; vector <vector <int> > a(n,vector <int>(m)); map <vector <int>,int > mp; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>a[i][j]; } mp[a[i]]++; } vector <int> cnt; 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); } 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; mp[a[i]]--; for(int k=0;k<m;k++){ if(a[i][k]==1)cnt[k]--; } for(auto v : mp){ if(v.ss>0){ int kol=0; for(int k=0;k<m;k++){ if(v.ff[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(v.ff[k]==1)cnt[k]++; } mx=max(mx,kol); } } mp[a[i]]++; for(int k=0;k<m;k++){ if(a[i][k]==1)cnt[k]++; } 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...