답안 #98473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98473 2019-02-23T18:30:28 Z pamaj Kronican (COCI16_kronican) C++14
0 / 100
6 ms 4480 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20;

int n, k;
int c[maxn][maxn];
int dp[1 << 20];
int dist[maxn];
int qt;
int solve(int mask)
{
	if(__builtin_popcount(mask) >= qt) return 0;

	if(dp[mask] != -1) return dp[mask];

	int ans = 1e9;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i == j or (mask & (1 << i)) or (mask & (1 << j))) continue;

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

	return dp[mask] = ans;
}


int main()
{
	cin >> n >> k;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
			cin >> c[i][j];
	}

	memset(dp, -1, sizeof(dp));

	qt = min(n - k, 0);

	cout << solve(0) << "\n";

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4480 KB Output isn't correct
2 Incorrect 5 ms 4352 KB Output isn't correct
3 Incorrect 6 ms 4352 KB Output isn't correct
4 Incorrect 6 ms 4352 KB Output isn't correct
5 Incorrect 6 ms 4480 KB Output isn't correct
6 Incorrect 6 ms 4480 KB Output isn't correct
7 Incorrect 6 ms 4480 KB Output isn't correct
8 Incorrect 5 ms 4352 KB Output isn't correct
9 Incorrect 6 ms 4480 KB Output isn't correct
10 Incorrect 5 ms 4352 KB Output isn't correct