#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=21;
int dp[1ll<<N], c[N][N], n, k, luu[N], dem;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(Task".inp", "r", stdin);
//freopen(Task".out", "w", stdout);
cin >> n >> k;
rep(i, 1, n)
rep(j, 1, n) cin >> c[i][j];
memset(dp, 0x32, sizeof dp);
rep(i, 0, (1ll<<n)-1) {
if(__builtin_popcount(i)<=k) dp[i]=0;
}
rep(i, 0, (1ll<<n)-1) {
int num=__builtin_popcount(i);
if(num<=k) continue;
dem=0;
rep(j, 1, n) {
if((i>>(j-1))&1) luu[++dem]=j;
}
rep(j, 1, dem) {
int state=i^(1ll<<(luu[j]-1));
int xx=1000000000;
rep(k1, 1, dem) {
if(j==k1) continue;
xx=min(xx, c[j][k1]);
}
dp[i]=min(dp[i], dp[state]+xx);
}
}
cout << dp[(1ll<<n)-1];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
8568 KB |
Output isn't correct |
2 |
Incorrect |
9 ms |
8704 KB |
Output isn't correct |
3 |
Incorrect |
8 ms |
8704 KB |
Output isn't correct |
4 |
Incorrect |
9 ms |
8704 KB |
Output isn't correct |
5 |
Incorrect |
18 ms |
8712 KB |
Output isn't correct |
6 |
Incorrect |
14 ms |
8712 KB |
Output isn't correct |
7 |
Incorrect |
26 ms |
8720 KB |
Output isn't correct |
8 |
Incorrect |
32 ms |
8736 KB |
Output isn't correct |
9 |
Incorrect |
241 ms |
8896 KB |
Output isn't correct |
10 |
Incorrect |
39 ms |
8896 KB |
Output isn't correct |