답안 #98100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98100 2019-02-20T16:57:47 Z dalgerok Izbori (COCI17_izbori) C++17
80 / 80
29 ms 392 KB
#include<bits/stdc++.h>
using namespace std;




int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    k -= 1;
    int a[n][m], cnt[m];
    memset(cnt, 0, sizeof(cnt));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
            a[i][j] -= 1;
        }
        cnt[a[i][0]] += 1;
    }
    cout << max_element(cnt, cnt + m) - cnt + 1 << "\n";
    int ans = 2e9;
    for(int mask = 0; mask + 1 < (1 << m); mask++){
        memset(cnt, 0, sizeof(cnt));
        for(int i = 0; i < n; i++){
            int j = 0;
            while((mask >> a[i][j]) & 1){
                j += 1;
            }
            cnt[a[i][j]] += 1;
        }
        if(max_element(cnt, cnt + m) - cnt == k){
            ans = min(ans, __builtin_popcount(mask));
        }
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 5 ms 392 KB Output is correct
12 Correct 15 ms 384 KB Output is correct
13 Correct 22 ms 384 KB Output is correct
14 Correct 17 ms 384 KB Output is correct
15 Correct 7 ms 384 KB Output is correct
16 Correct 29 ms 384 KB Output is correct
17 Correct 13 ms 384 KB Output is correct
18 Correct 26 ms 384 KB Output is correct
19 Correct 28 ms 384 KB Output is correct
20 Correct 28 ms 384 KB Output is correct