# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
98471 | wjoao | Kronican (COCI16_kronican) | C++11 | 2058 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define maxn 20
#define inf 0x3f3f3f3f
#define maxb (1<<maxn)
using namespace std;
int g[50][50], n, k, pd[maxb];
int solve(int bitmask){
if(__builtin_popcount(bitmask) == k) return 0;
int best = inf;
for(int i = 0; i < n; i++){
if(!((1<<i)&bitmask)){
int cost = inf;
for(int j = 0; j < n; j++){
if(i==j) continue;
if(!((1<<j)&bitmask)){
cost = min(cost, g[i][j]);
}
}
best = min(best, cost + solve(bitmask|(1<<i)));
}
}
return best;
}
int main(){
scanf(" %d %d", &n, &k);
k = n-k;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++ )
scanf(" %d", &g[i][j]);
printf("%d\n", solve(0));
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |