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>
/*
O(n^2 log n) what
*/
int main(){
std::ios::sync_with_stdio(0);
std::cin.tie(0);
int n;
std::cin>>n;
std::vector<std::vector<int>> netrp(n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
int x;
std::cin>>x;
netrp[i].push_back(x);
}
}
std::vector<long long> ccosts(n);
for(int i=1;i<n;i++){
std::vector<long long> nccosts(n,1e18);
for(int j=0;j<n;j++){
for(int k=0;!(i&k);k++){
nccosts[j^k^(i&-i)]=std::min(nccosts[j^k^(i&-i)],ccosts[j]+netrp[j][j^k^(i&-i)]);
}
}
ccosts=nccosts;
}
long long mn=1e18;
for(int i=0;i<n;i++)mn=std::min(mn,ccosts[i]);
std::cout<<mn<<'\n';
}
# | 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... |