답안 #98492

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98492 2019-02-23T19:04:50 Z pamaj Zoltan (COCI16_zoltan) C++14
0 / 140
1000 ms 4480 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 20;

#pragma GCC optimize ("Ofast")

int n, k;
int c[maxn][maxn];
int dp[1 << 20];

int32_t main()
{	
	ios::sync_with_stdio(false), cin.tie(nullptr);
	cin >> n >> k;

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


	for(int mask = 0; mask < (1 << n); mask++)
	{
		if(__builtin_popcount(mask) <= k) {dp[mask] = 0; continue;}

		int ans = 1e7;

		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, dp[mask ^ (1 << i)] + c[i][j]);
			}
		}

		dp[mask] = ans;
	}

	cout << dp[(1 << n) - 1] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 4480 KB Output isn't correct
2 Incorrect 10 ms 4480 KB Output isn't correct
3 Incorrect 11 ms 4480 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Execution timed out 1059 ms 3956 KB Time limit exceeded
6 Execution timed out 1079 ms 3908 KB Time limit exceeded
7 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)