Submission #676502

#TimeUsernameProblemLanguageResultExecution timeMemory
676502penguin133Kronican (COCI16_kronican)C++17
100 / 100
479 ms8588 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int A[25][25], ans = 1e18, dp[(1<<20) + 1]; main(){ int n,k; cin >> n >> k; for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin >> A[i][j]; for(int i=(1<<n)-2;i>=0;i--){ dp[i] = 1e18; int cnt =0; for(int j=0;j<n;j++){ if(!(i >> j & 1)){ int mini = 1e9; for(int x=0;x<n;x++){ if(i >> x & 1)mini = min(mini, A[j][x]); } dp[i] = min(dp[i], dp[i+(1<<j)] + mini); } else cnt++; } if(cnt <= k)ans = min(ans, dp[i]); } cout << (n == k ? 0 : ans); }

Compilation message (stderr)

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