# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84669 | wjoao | Kronican (COCI16_kronican) | C++11 | 2072 ms | 648 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 maxn 25
#define maxn2 ((1<<21)+5)
#define inf 0x3f3f3f3f
using namespace std;
int ma[maxn][maxn], pd[maxn2][maxn], n, k;
int solve(int bitmask, int v, int count){
if(count >= k+1) return 0;
int sol = inf;
for(int i = 1; i <= n; i++){
if(bitmask & (1<<i)) continue;
sol = min(sol,
ma[v][i] + solve(bitmask|(1<<i), i, count+1)
);
}
return sol;
}
int main(){
scanf(" %d %d", &n, &k);
k = n-k;
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++ )
scanf("%d", &ma[i][j]);
for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++ )
ma[i][j] = min(ma[i][j], ma[j][i]);
printf("%d\n", solve(1, 0, 0));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |