# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
143534 |
2019-08-14T14:09:19 Z |
Ort |
Izbori (COCI17_izbori) |
C++11 |
|
45 ms |
504 KB |
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(c) (c).begin(),(c).end()
#define sz(a) ((int)(a.size()))
#define ll long long
#define LINF (ll)1e18
#define INF (int)1e9
#define MINF 0x3F3F3F3F
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 105
#define N 17
#define watch(x) cerr<<#x<<" = "<<(x)<<endl;
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n, m, k, sol, mx, c, t;
int fq[MAX], mat[MAX][N];
bool sub[N];
int main() {
IO;
cin >> n >> m >> k; k--;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin >> mat[i][j], mat[i][j]--;
for(int i=0;i<n;i++) fq[mat[i][0]]++;
for(int i=0;i<n;i++) if(fq[i]>mx) mx = fq[i], t = i;
cout << t+1 << "\n";
for(int i=0;i<(1<<m);i++) {
MEM(sub, 0); MEM(fq, 0); c = 0; mx = -1; t = -1;
for(int j=0;j<m;j++) if((i>>j)&1) sub[j] = true, c++;
for(int j=0;j<n;j++)
for(int k=0;k<m;k++)
if(sub[mat[j][k]]) {
fq[mat[j][k]]++;
break;
}
for(int j=0;j<m;j++) if(fq[j]>mx) mx = fq[j], t = j;
if(t==k) sol = max(sol, c);
}
cout << m-sol;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Partially correct |
7 ms |
376 KB |
Partially correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
11 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Partially correct |
7 ms |
376 KB |
Partially correct |
9 |
Correct |
7 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
376 KB |
Output is correct |
12 |
Correct |
21 ms |
376 KB |
Output is correct |
13 |
Correct |
38 ms |
376 KB |
Output is correct |
14 |
Correct |
20 ms |
380 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
44 ms |
376 KB |
Output is correct |
17 |
Correct |
21 ms |
376 KB |
Output is correct |
18 |
Correct |
41 ms |
388 KB |
Output is correct |
19 |
Correct |
44 ms |
376 KB |
Output is correct |
20 |
Correct |
45 ms |
504 KB |
Output is correct |