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;
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=0;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],num[li],dp[li][li];
int cev;
string s;
vector<int> v;
int32_t main(void){
fio();
cin>>n;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
FOR{
for(int j=0;j<n;j++)cin>>a[i][j];
}
cev=inf;
for(int i=1;i<n;i++){
int msd=i&(-i);
for(int x=0;x<n;x++){
int l=(x^msd)&(~(msd-1));
int r=msd+l-1;
dp[i][x]=inf;
for(int xx=l;xx<=r;xx++){
dp[i][x]=min(dp[i][x],dp[i-1][xx]+a[x][xx]);
if(i==n-1)cev=min(cev,dp[i][x]);
}
}
}
cout<<cev<<endl;
return 0;
}
# | 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... |