제출 #98471

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

kronican.cpp: In function 'int main()':
kronican.cpp:29: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:34:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf(" %d", &g[i][j]);
       ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...