제출 #84669

#제출 시각아이디문제언어결과실행 시간메모리
84669wjoaoKronican (COCI16_kronican)C++11
10 / 100
2072 ms648 KiB
#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) 메시지

kronican.cpp: In function 'int main()':
kronican.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %d %d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~~~
kronican.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &ma[i][j]);
     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...