# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651404 | BidoTeima | Izbori (COCI17_izbori) | C++17 | 19 ms | 312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: BidoTeima
LANG: C++11
TASK: Izbori
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
if(str=="NOF")return;
if(str.size())
moo(str);
else{
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
}
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void moo(string fileName){
freopen((fileName+".in").c_str(),"r",stdin);
freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc \
int tttttt/*,subtask*/; \
cin >> tttttt/* >> subtask*/; \
while (tttttt--)/*end
*/
int main()
{
//ACPLS("");
int n,m,k;
cin>>n>>m>>k;
vector<vector<int>>a(n,vector<int>(m));
int f[m+1]={0};
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin>>a[i][j];
if(j == 0)
++f[a[i][j]];
}
}
int winner = 1;
for(int i = 1; i <= m; i++){
if(f[i] > f[winner])
winner = i;
}
cout<<winner<<'\n';
bool vis[m+1]={0};
int ans = m-1;
for(int i = 0; i < (1<<m); i++){
if(i&(1<<(k-1)))continue;
int freq[m+1]={0};
for(int j = 0; j < n; j++){
for(int k = 0; k < m; k++){
if(!(i&(1<<(a[j][k]-1)))){
++freq[a[j][k]];
break;
}
}
}
if(max_element(freq+1,freq+m+1)-freq == k){
ans=min(ans,__builtin_popcount(i));
}
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |