Submission #98526

# Submission time Handle Problem Language Result Execution time Memory
98526 2019-02-23T20:40:20 Z sams Kronican (COCI16_kronican) C++14
0 / 100
11 ms 8704 KB
#include <bits/stdc++.h>

using namespace std;

const int maxmask = (1<<20)+10, inf = 2e6+10;

int n, k, m[30][30];

int dp[maxmask];

int solve(int mask, int qtd){
	
	if(dp[mask] != -1) return dp[mask];
	if(qtd > k) return 0;
	int ans=1e9;
	for(int i = 1; i<=n;++i){
		if(mask&(1<<i)==true) continue;

		for(int j = 1 ; j <= n ; ++j){
			if(mask&(1<<j)==true) continue;

			if(i==j) continue;

			ans = min(ans, m[i][j]+solve(mask|(1<<i), qtd+1));
		}
	}

	return dp[mask]=ans;
}
int main(){

	cin >> n >> k;

	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			cin >> m[i][j];
	
	memset(dp, -1, sizeof dp);

	k=n-k;
	cout << solve(0, 0) << "\n";
}

Compilation message

kronican.cpp: In function 'int solve(int, int)':
kronican.cpp:17:17: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   if(mask&(1<<i)==true) continue;
           ~~~~~~^~~~~~
kronican.cpp:20:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    if(mask&(1<<j)==true) continue;
            ~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4480 KB Output isn't correct
2 Incorrect 7 ms 4352 KB Output isn't correct
3 Incorrect 5 ms 4352 KB Output isn't correct
4 Incorrect 5 ms 4480 KB Output isn't correct
5 Incorrect 6 ms 4352 KB Output isn't correct
6 Incorrect 7 ms 4480 KB Output isn't correct
7 Incorrect 6 ms 4352 KB Output isn't correct
8 Incorrect 7 ms 4352 KB Output isn't correct
9 Runtime error 11 ms 8704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 11 ms 8704 KB Execution killed with signal 11 (could be triggered by violating memory limits)