# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89152 | 2018-12-10T15:45:49 Z | asifthegreat | Kronican (COCI16_kronican) | C++14 | 1687 ms | 4776 KB |
#include <bits/stdc++.h> using namespace std; const int N = 20; int n,k; int ara[N][N]; int dp[1<<N]; bool check(int mask,int number){return mask&(1<<number);} int Set(int mask,int number){return mask = mask|(1<<number);} int call(int mask) { if(__builtin_popcount(mask) == n-k)return 0; int &ret = dp[mask]; if(ret != -1)return ret; ret = (1<<30); for(int i = 0; i < n;i++){ if(check(mask,i))continue; for(int j = 0; j < n;j++){ if(i == j or check(mask,j))continue; ret = min(ret,call(Set(mask,j))+ara[j][i]); } } return ret; } int main() { memset(dp,-1,sizeof dp); scanf("%d%d",&n,&k); for(int i = 0; i < n;i++){ for(int j = 0; j < n;j++){ scanf("%d",&ara[i][j]); } } printf("%d\n",call(0)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4344 KB | Output is correct |
2 | Correct | 6 ms | 4596 KB | Output is correct |
3 | Correct | 6 ms | 4596 KB | Output is correct |
4 | Correct | 6 ms | 4596 KB | Output is correct |
5 | Correct | 18 ms | 4596 KB | Output is correct |
6 | Correct | 35 ms | 4596 KB | Output is correct |
7 | Correct | 68 ms | 4596 KB | Output is correct |
8 | Correct | 145 ms | 4628 KB | Output is correct |
9 | Correct | 1687 ms | 4776 KB | Output is correct |
10 | Correct | 170 ms | 4776 KB | Output is correct |