# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087982 |
2024-09-13T16:20:42 Z |
Has2008 |
Izbori (COCI17_izbori) |
C++17 |
|
26 ms |
348 KB |
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl endl
const int mod = 1e9 + 7;
const int maxn = 105;
int n, m, k, arr[maxn][20], ans = INT_MAX;
vector < int > v;
int the_winner()
{
bool out[20] = { };
for(auto i : v) out[i] = 1;
int frq[20] = { }, winner = -1, mx = -1;
for(int i = 0; i < n; i++)
{
int j;
for(j = 0; j < m; j++) if(!out[arr[i][j]]) break;
if(j == m) continue;
frq[arr[i][j]]++;
if(frq[arr[i][j]] > mx) winner = arr[i][j], mx = frq[arr[i][j]];
}
return winner;
}
void rec(int i, int cnt)
{
if(i == m)
{
if(the_winner() == k) ans = min(ans, cnt);
return;
}
v.push_back(i + 1);
rec(i + 1, cnt + 1);
v.pop_back();
rec(i + 1, cnt);
}
void solve()
{
cin >> n >> m >> k;
int frq[m + 5] = { };
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> arr[i][j];
if(j == 0) frq[arr[i][j]] ++;
}
}
int mx = -1, winner = -1;
for(int i = 1; i <= m; i++) if(frq[i] > mx) mx = frq[i], winner = i;
cout << winner << endl;
rec(0, 0);
cout << ans << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tt = 1;
//cin >> tt;
while(tt--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Partially correct |
1 ms |
348 KB |
Partially correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
6 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Partially correct |
2 ms |
348 KB |
Partially correct |
9 |
Partially correct |
4 ms |
348 KB |
Partially correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
348 KB |
Output is correct |
12 |
Correct |
12 ms |
348 KB |
Output is correct |
13 |
Partially correct |
22 ms |
348 KB |
Partially correct |
14 |
Correct |
12 ms |
348 KB |
Output is correct |
15 |
Correct |
3 ms |
348 KB |
Output is correct |
16 |
Partially correct |
25 ms |
348 KB |
Partially correct |
17 |
Partially correct |
13 ms |
344 KB |
Partially correct |
18 |
Correct |
22 ms |
348 KB |
Output is correct |
19 |
Correct |
25 ms |
348 KB |
Output is correct |
20 |
Correct |
26 ms |
348 KB |
Output is correct |