# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1085591 | 2024-09-08T13:07:07 Z | CrabCNH | Kronican (COCI16_kronican) | C++14 | 53 ms | 17244 KB |
#include <bits/stdc++.h> #define int long long #define pii pair <int, int> #define fi first #define se second using namespace std; const int N = 20 + 5; const int inf = 1e18 + 7; int n, k; int c[N][N]; int dp[1 << 20]; void read () { #define task "crab" if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } } bool bit (int x, int i) { return ((x >> i) & 1); } int flip (int x, int i) { return (x | (1 << i)); } signed main () { ios_base :: sync_with_stdio (0); cin.tie (0); read (); cin >> n >> k; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= n; j ++) { cin >> c[i][j]; } } memset(dp, 0x3f, sizeof dp); int ans = dp[0]; dp[(1 << n) - 1] = 0; for (int x = (1 << n) - 1; x >= 0; x --) { for (int i = 1; i <= n; i ++) { if (bit(x, i - 1)) { int y = flip (x, i); int cost = inf; for (int j = 1; j <= n; j ++) { if (bit (y, j - 1)) { cost = min(cost, c[i][j]); } } dp[y] = min(dp[y], dp[x] + cost); } } } for (int mask = 1; mask < (1 << n); mask ++) { if (__builtin_popcount(mask) <= k) ans = min(ans, dp[mask]); } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 8536 KB | Output isn't correct |
2 | Incorrect | 3 ms | 8540 KB | Output isn't correct |
3 | Incorrect | 4 ms | 8540 KB | Output isn't correct |
4 | Incorrect | 3 ms | 8480 KB | Output isn't correct |
5 | Incorrect | 8 ms | 8540 KB | Output isn't correct |
6 | Incorrect | 14 ms | 8540 KB | Output isn't correct |
7 | Incorrect | 26 ms | 8540 KB | Output isn't correct |
8 | Incorrect | 53 ms | 8540 KB | Output isn't correct |
9 | Runtime error | 9 ms | 17244 KB | Execution killed with signal 11 |
10 | Runtime error | 10 ms | 17200 KB | Execution killed with signal 11 |