# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89144 | 2018-12-10T15:05:28 Z | RezwanArefin01 | Kronican (COCI16_kronican) | C++17 | 630 ms | 4792 KB |
///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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4344 KB | Output is correct |
2 | Incorrect | 6 ms | 4468 KB | Output isn't correct |
3 | Incorrect | 5 ms | 4544 KB | Output isn't correct |
4 | Incorrect | 5 ms | 4696 KB | Output isn't correct |
5 | Incorrect | 11 ms | 4696 KB | Output isn't correct |
6 | Incorrect | 18 ms | 4696 KB | Output isn't correct |
7 | Incorrect | 31 ms | 4792 KB | Output isn't correct |
8 | Incorrect | 62 ms | 4792 KB | Output isn't correct |
9 | Incorrect | 630 ms | 4792 KB | Output isn't correct |
10 | Incorrect | 65 ms | 4792 KB | Output isn't correct |