# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
706568 | YugiHacker | Kronican (COCI16_kronican) | C++14 | 488 ms | 4504 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>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn
#define bit(n,i) ((n>>i)&1)
using namespace std;
int n, k, f[1<<22];
int c[22][22];
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
f0 (i, n) f0 (j, n) cin >> c[i][j];
int ans = 1e9;
for (int x=(1<<n)-1; x; x--)
{
if (x!= (1<<n)-1) f[x] = 1e9;
if (__builtin_popcount(x) < k) continue;
f0 (i, n) if (bit(x, i))
{
f0 (j, n) if (!bit(x, j))
f[x] = min(f[x], f[x+(1<<j)] + c[j][i]);
}
if (__builtin_popcount(x) == k) ans = min(ans, f[x]);
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |