# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98800 | sofhiasouza | Kronican (COCI16_kronican) | C++14 | 1759 ms | 8576 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 inf 0x3f3f3f3f
using namespace std;
int main()
{
int n, k, dp[2100000], m[22][22];
cin >> n >> k;
k = n - k;
memset(dp, inf, sizeof dp);
for(int i = 0 ; i < n ; i++)
{
for(int j = 0 ; j < n ; j++)
{
cin >> m[i][j];
}
}
int menor = inf;
dp[0] = 0;
for(int mask = 0 ; mask < (1 << n+1) ; mask++)
{
int cont = 0;
for(int i = 0 ; i < n ; i++)
{
if(mask&(1 << i))
{
cont++;
continue;
}
for(int j = 0 ; j < n ; j++)
{
if(mask&(1 << j) or j == i) continue;
dp[mask|(1 << j)] = min(dp[mask|(1 << j)], dp[mask]+m[j][i]);
}
}
if(cont >= k) menor = min(menor, dp[mask]);
}
cout << menor << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |