#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
#define _ << " " <<
const lo inf = 1000000000000000000;
const lo li = 2050;
const lo mod = 1000000007;
int n,m,a[li][li],k,flag,t,p[li],l[li],r[li];
int cev;
string s;
vector<int> v;
unordered_map<int,int> dp;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int dfs(int node,int start,int end,int mask){
if(start+1==end){return a[start][end];}
int cevv=inf;
if(dp.find(mask)!=dp.end())return dp[mask];
for(int i=start;i<=mid;i++){
if(mask&(1<<i))continue;
for(int j=mid+1;j<=end;j++){
if(mask&(1<<j))continue;
cevv=min(cevv,dfs(node*2,start,mid,mask|(1<<i))+dfs(node*2+1,mid+1,end,mask|(1<<j))+a[i][j]);
}
}
return dp[mask]=cevv;
}
int32_t main(void){
fio();
cin>>n;
FOR{
for(int j=1;j<=n;j++)cin>>a[i][j];
}
cout<<dfs(1,1,n,0)<<endl;
//~ cout<<cev<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |