Submission #84682

#TimeUsernameProblemLanguageResultExecution timeMemory
84682wjoaoKronican (COCI16_kronican)C++11
100 / 100
1167 ms8884 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], n, k; int solve(int bitmask, int count){ if(pd[bitmask] != inf) return pd[bitmask]; if(count >= k) return 0; for(int i = 0; i < n; i++){ if(bitmask & (1<<i)) continue; for(int j = 0; j < n; j++){ if(i==j) continue; if(bitmask & (1<<j)) continue; pd[bitmask] = min(pd[bitmask], ma[i][j] + solve(bitmask|(1<<i), count+1) ); } } return pd[bitmask]; } int main(){ scanf(" %d %d", &n, &k); memset(pd, inf, sizeof pd); k = n-k; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++ ) scanf("%d", &ma[i][j]); printf("%d\n", solve(0, 0)); return 0; }

Compilation message (stderr)

kronican.cpp: In function 'int main()':
kronican.cpp:28: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:32: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...