Submission #89144

#TimeUsernameProblemLanguageResultExecution timeMemory
89144RezwanArefin01Kronican (COCI16_kronican)C++17
10 / 100
630 ms4792 KiB
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit; #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 20; int dp[1 << N], a[N][N], n, k; int main() { scanf("%d %d", &n, &k); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { scanf("%d", &a[i][j]); } } memset(dp, 63, sizeof dp); for(int mask = 0; mask < (1 << n); mask++) { if(__builtin_popcount(mask) <= k) { dp[mask] = 0; continue; } vector<int> v; for(int i = 0; i < n; i++) if(mask >> i & 1) v.push_back(i); for(int i = 0; i < v.size(); i++) { for(int j = 0; j < v.size(); j++) if(i != j) { dp[mask] = min(dp[mask], dp[mask ^ (1 << i)] + a[v[i]][v[j]]); } } } printf("%d\n", dp[(1 << n) - 1]); }

Compilation message (stderr)

kronican.cpp: In function 'int main()':
kronican.cpp:26:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0; i < v.size(); i++) {
                        ~~^~~~~~~~~~
kronican.cpp:27:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0; j < v.size(); j++) if(i != j) {
                            ~~^~~~~~~~~~
kronican.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
kronican.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a[i][j]); 
             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...