# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89144 | RezwanArefin01 | Kronican (COCI16_kronican) | C++17 | 630 ms | 4792 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.
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 20;
int dp[1 << N], a[N][N], n, k;
int main() {
scanf("%d %d", &n, &k);
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
scanf("%d", &a[i][j]);
}
}
memset(dp, 63, sizeof dp);
for(int mask = 0; mask < (1 << n); mask++) {
if(__builtin_popcount(mask) <= k) {
dp[mask] = 0;
continue;
}
vector<int> v;
for(int i = 0; i < n; i++) if(mask >> i & 1) v.push_back(i);
for(int i = 0; i < v.size(); i++) {
for(int j = 0; j < v.size(); j++) if(i != j) {
dp[mask] = min(dp[mask], dp[mask ^ (1 << i)] + a[v[i]][v[j]]);
}
}
}
printf("%d\n", dp[(1 << n) - 1]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |