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