This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long maxn=2500;
long long dp[maxn][maxn],n,cost[maxn][maxn];
long long inf=1e18;
void vorod(){
cin>>n;
for(long long i=0;i<n;i++){
for(long long j=0;j<n;j++){
cin>>cost[i][j];
}
}
}
void solve(){
for(long long lev=1;lev<n;lev++){
long long pae=(lev&(-lev));
for(long long i=0;i<n;i++){
long long l=(i^pae)&(~(pae-1));
long long r=l+pae;
dp[lev][i]=inf;
for(long long j=l;j<r;j++){
dp[lev][i]=min(dp[lev][i],dp[lev-1][j]+cost[i][j]);
}
}
}
}
void khor(){
long long res=inf;
for(long long i=0;i<n;i++){
res=min(res,dp[n-1][i]);
}
cout<<res<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vorod();
solve();
khor();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |