Submission #98800

#TimeUsernameProblemLanguageResultExecution timeMemory
98800sofhiasouzaKronican (COCI16_kronican)C++14
100 / 100
1759 ms8576 KiB
#include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; int main() { int n, k, dp[2100000], m[22][22]; cin >> n >> k; k = n - k; memset(dp, inf, sizeof dp); for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < n ; j++) { cin >> m[i][j]; } } int menor = inf; dp[0] = 0; for(int mask = 0 ; mask < (1 << n+1) ; mask++) { int cont = 0; for(int i = 0 ; i < n ; i++) { if(mask&(1 << i)) { cont++; continue; } for(int j = 0 ; j < n ; j++) { if(mask&(1 << j) or j == i) continue; dp[mask|(1 << j)] = min(dp[mask|(1 << j)], dp[mask]+m[j][i]); } } if(cont >= k) menor = min(menor, dp[mask]); } cout << menor << endl; }

Compilation message (stderr)

kronican.cpp: In function 'int main()':
kronican.cpp:19:35: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
  for(int mask = 0 ; mask < (1 << n+1) ; mask++)
                                  ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...