Submission #367453

#TimeUsernameProblemLanguageResultExecution timeMemory
367453FatihSolakKronican (COCI16_kronican)C++17
100 / 100
416 ms4588 KiB
#include <bits/stdc++.h> #define N 20 using namespace std; int dist[N][N]; int dp[(1<<N)]; void solve(){ int n,k; cin >> n >> k; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cin >> dist[i][j]; } } for(int i=1;i<(1<<n);i++){ dp[i] = 1e9; } int ans = 1e9; for(int i=0;i<(1<<n);i++){ vector<int> un; for(int j=0;j<n;j++){ if(!(i & (1<<j))){ un.push_back(j); } } if(un.size() == k){ ans = min(ans,dp[i]); } for(auto u:un){ int mini = 1e9; for(auto v:un){ if(u == v)continue; mini = min(mini,dist[u][v]); } dp[i+(1<<u)] = min(dp[i+(1<<u)],dp[i]+mini); } } cout << ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }

Compilation message (stderr)

kronican.cpp: In function 'void solve()':
kronican.cpp:25:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |         if(un.size() == k){
      |            ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...