Submission #706568

#TimeUsernameProblemLanguageResultExecution timeMemory
706568YugiHackerKronican (COCI16_kronican)C++14
100 / 100
488 ms4504 KiB
#include<bits/stdc++.h> #define el cout<<"\n" #define f0(i,n) for(int i=0;i<n;++i) #define f1(i,n) for(int i=1;i<=n;++i) #define maxn #define bit(n,i) ((n>>i)&1) using namespace std; int n, k, f[1<<22]; int c[22][22]; main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> k; f0 (i, n) f0 (j, n) cin >> c[i][j]; int ans = 1e9; for (int x=(1<<n)-1; x; x--) { if (x!= (1<<n)-1) f[x] = 1e9; if (__builtin_popcount(x) < k) continue; f0 (i, n) if (bit(x, i)) { f0 (j, n) if (!bit(x, j)) f[x] = min(f[x], f[x+(1<<j)] + c[j][i]); } if (__builtin_popcount(x) == k) ans = min(ans, f[x]); } cout << ans; }

Compilation message (stderr)

kronican.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...