# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
180285 | awlintqaa | Kronican (COCI16_kronican) | C++14 | 1744 ms | 8696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 500
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;//998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
ll n,k;
ll a[29][29];
ll dp[(1<<20)+9];
ll bt(ll mask,ll crnt){
if(crnt==k)return 0;
ll &ret=dp[mask];
if(ret!=-1)return ret;
ret=1e18;
for(ll i=0;i<n;i++){
for(ll j=0;j<n;j++){
if(i==j)C;
if((mask&(1<<i)) || (mask&(1<<j)))C;
ret=min(ret,bt(mask|(1<<i),crnt-1)+a[i][j]);
}
}
return ret;
}
int main(){
mem(dp,-1);
cin>>n>>k;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
cout<<bt(0,n)<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |