# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
443550 | penguinhacker | Kronican (COCI16_kronican) | C++14 | 816 ms | 4420 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
int n, k, c[20][20], dp[1<<20];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
for (int i=0; i<n; ++i)
for (int j=0; j<n; ++j)
cin >> c[i][j];
memset(dp, 0x3f, sizeof(dp));
dp[(1<<n)-1]=0;
int ans=69696969;
for (int i=(1<<n)-1; i; --i) {
int x=__builtin_popcount(i);
if (x<k)
continue;
if (x==k) {
ans=min(ans, dp[i]);
continue;
}
for (int j=0; j<n; ++j)
if (i&1<<j)
for (int k2=0; k2<n; ++k2)
if (j^k2&&i&1<<k2)
dp[i^1<<j]=min(dp[i^1<<j], dp[i]+c[j][k2]);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |