| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 176010 | fbosnjak | Izbori (COCI17_izbori) | C++14 | 709 ms | 504 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 maxn = 105;
const int maxm = 16;
int N, M, K;
int a;
int cnt[maxm];
queue <int> q[maxn];
int main()
{
	cin >> N >> M >> K;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			{cin >> a; q[i].push(a);}
	for (int i = 0; i < N; i++)
		cnt[q[i].front()]++;
	int sol;
	int ima = 0;
	for (int i = 1; i <= M; i++)
		if (cnt[i] > ima) {ima = cnt[i]; sol = i;}
	
	cout << sol << endl;
	int rj = 1e9;
	int m = (1 << M);
	for (int i = 0; i < m - 1; i++)
	{
		int curr = __builtin_popcount(i);
		queue <int> newq[N];
		for (int j = 0; j < N; j++)
			newq[j] = q[j];
		for (int j = 0; j < N; j++)
			while (((1 << (newq[j].front() - 1)) & i) == (1 << (newq[j].front() - 1))) 
				newq[j].pop();
		memset(cnt, 0, sizeof cnt);
		for (int j = 0; j < N; j++) 
			if (!newq[j].empty())
				cnt[newq[j].front()]++;
		int ima = 0;
		for (int j = 1; j <= M; j++)
			if (cnt[j] > ima) {ima = cnt[j]; sol = j;}
		if (sol == K) rj = min(rj, curr); 
	}
	cout << rj << endl;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
