답안 #1089017

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1089017 2024-09-15T18:47:21 Z vjudge1 Izbori (COCI17_izbori) C++17
50 / 80
27 ms 464 KB
#include "bits/stdc++.h"
const signed MOD = 1e9 + 7;
const signed mod = 998244353;
using namespace std;
#define all(x) x.begin(), x.end()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define co cout <<
#define S second
#define F first
int n, m, k, ans, a[105][20];

void sol(vector<bool> v, int cn) {
    if (cn == m) return;
    v.pb(0);
    sol(v, cn + 1);
    v.pop_back();
    v.pb(1);
    sol(v, cn + 1);
    int f[20] = {};
    for (int i = 0; i < n; i++) {
        int j = 0;
        while (j < m && v[a[i][j]]) j++;
        if (j < m) f[a[i][j]]++;
    }
    int mx = 0, num;

    for (int i = 1; i <= m; i++) {
        if (f[i] > mx) {
            mx = f[i];
            num = i;
        }
    }
    if (num == k) ans = min(ans, cn);
    if (cn == 0) co num << '\n';
}

void solve() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    vector<bool> v;
    ans = m - 1;
    sol(v, 0);
    co ans;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    signed t = 1;
    // cin >> t;
    while (t--) solve();
}

Compilation message

izbori.cpp: In function 'void sol(std::vector<bool>, int)':
izbori.cpp:37:28: warning: 'num' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     if (cn == 0) co num << '\n';
      |                            ^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 2 ms 348 KB Partially correct
2 Partially correct 4 ms 348 KB Partially correct
3 Partially correct 1 ms 344 KB Partially correct
4 Correct 4 ms 348 KB Output is correct
5 Partially correct 2 ms 452 KB Partially correct
6 Partially correct 1 ms 348 KB Partially correct
7 Correct 1 ms 348 KB Output is correct
8 Partially correct 5 ms 348 KB Partially correct
9 Partially correct 3 ms 348 KB Partially correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Partially correct 12 ms 464 KB Partially correct
13 Partially correct 23 ms 348 KB Partially correct
14 Correct 8 ms 348 KB Output is correct
15 Partially correct 3 ms 348 KB Partially correct
16 Partially correct 26 ms 348 KB Partially correct
17 Partially correct 10 ms 344 KB Partially correct
18 Partially correct 21 ms 344 KB Partially correct
19 Partially correct 21 ms 348 KB Partially correct
20 Partially correct 27 ms 348 KB Partially correct