| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 236724 | VEGAnn | Izbori (COCI17_izbori) | C++14 | 42 ms | 768 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.
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int oo = int(2e9);
bool mrk[N];
int n, m, k, ans = oo, kol[N], per[N][N];
int who(int mask){
    fill(kol, kol + m, 0);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++)
            if (!(mask & (1 << per[i][j]))) {
                kol[per[i][j]]++;
                break;
            }
    }
    int mx = -1;
    for (int i = 0; i < m; i++)
        mx = max(mx, kol[i]);
    for (int i = 0; i < m; i++)
        if (mx == kol[i])
            return i;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL
    cin >> n >> m >> k;
    k--;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
        cin >> per[i][j];
        per[i][j]--;
    }
    cout << who(0) + 1 << '\n';
    for (int mask = 0; mask < (1 << m) - 1; mask++)
        if (who(mask) == k)
            ans = min(ans, __builtin_popcount(mask));
    cout << ans;
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
