답안 #236722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236722 2020-06-03T06:45:30 Z VEGAnn Izbori (COCI17_izbori) C++14
44 / 80
19 ms 768 KB
#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 << 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);

    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

izbori.cpp: In function 'int who(int)':
izbori.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5 ms 640 KB Partially correct
2 Partially correct 6 ms 384 KB Partially correct
3 Partially correct 5 ms 640 KB Partially correct
4 Partially correct 7 ms 640 KB Partially correct
5 Partially correct 5 ms 640 KB Partially correct
6 Partially correct 5 ms 512 KB Partially correct
7 Partially correct 5 ms 512 KB Partially correct
8 Partially correct 7 ms 384 KB Partially correct
9 Partially correct 6 ms 768 KB Partially correct
10 Partially correct 5 ms 512 KB Partially correct
11 Correct 6 ms 640 KB Output is correct
12 Partially correct 10 ms 640 KB Partially correct
13 Partially correct 15 ms 640 KB Partially correct
14 Partially correct 10 ms 640 KB Partially correct
15 Partially correct 6 ms 640 KB Partially correct
16 Partially correct 19 ms 768 KB Partially correct
17 Partially correct 11 ms 640 KB Partially correct
18 Correct 16 ms 768 KB Output is correct
19 Partially correct 18 ms 768 KB Partially correct
20 Partially correct 17 ms 768 KB Partially correct