Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //counting dp[mask].
- for (int i = 0; i < (1 << n); ++i) {
- vector <int> bit; //bits of our num
- if (bit.size() <= k) continue;
- for (int b1: bit) {
- int min_cost = INF;
- for (int b2: bit) {
- if (b1 == b2) continue
- min_cost = min(min_cost, cost[b1][b2]);
- }
- dp[i] = min(dp[i], dp[i - (1 << b1)] + min_cost);
- }
- }
- cout << dp[(1 << n) - 1] << endl;
Advertisement
Add Comment
Please, Sign In to add comment