# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884566 | vjudge1 | Kronican (COCI16_kronican) | C++17 | 690 ms | 4520 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;
//#define int long long
const int mod = 1e9 + 7;
const int maxn = 20;
const int infinito = 1e9;
int n,k;
int v[maxn][maxn];
int dp[(1<<maxn) + 10];
signed main(){
cin >> n >> k;
for(int i = 0; i < n; i++){
for(int y = 0; y < n; y++){
cin >> v[i][y];
}
}
for(int i = 0; i <= (1<<n)-1; i++){
dp[i] = infinito;
}
dp[(1<<n)-1] = 0;
int resul = infinito;
for(int i = (1<<n)-1; i >= 0; i--){
int uns = __builtin_popcount(i);
for(int y = 0; y < n; y++){
if(((i&(1<<y)) < 1)){
continue;
}
for(int j = 0; j < n; j++){
if(j != y && ((i&(1<<j)) >= 1)){
dp[i^(1<<y)] = min(dp[i^(1<<y)], dp[i] + v[y][j]);
}
}
}
if(uns <= k){
//cout << i << " " << dp[i] << endl;
resul = min(resul, dp[i]);
}
}
cout << resul << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |