# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136633 | DanerZein | Roller Coaster Railroad (IOI16_railroad) | C++14 | 245 ms | 165352 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.
#include "railroad.h"
#include <bits/stdc++.h>
#define MAX 10000000000
using namespace std;
long long dp[100][100000];
long long dist[100][100];
long long l,tam;
long long tsp(){
for(int mask=0;mask<(1<<tam);mask++){
for(int i=0;i<tam;i++){
if(mask==(1<<i)){
dp[i][mask]=0;
}
else{
if(mask&(1<<i)){
dp[i][mask]=MAX;
for(int j=0;j<tam;j++){
int newmask=mask^(1<<i);
if(newmask&(1<<j))
dp[i][mask]=min(dp[i][mask],dist[i][j]+dp[j][newmask]);
}
}
}
}
}
long long r=MAX;
for(int i=0;i<tam;i++){
r=min(r,dp[i][(1<<tam)-1]);
}
return r;
}
long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) {
tam=s.size();
for(int i=0;i<s.size();i++){
for(int j=i+1;j<s.size();j++){
int r1=t[i]-s[j];
int r2=t[j]-s[i];
// cout<<t[i]<<" "<<s[j]<<" "<<t[j]<<" "<<s[i]<<endl;
r1=max(r1,0);
r2=max(r2,0);
dist[i][j]=r1;
dist[j][i]=r2;
}
}
long long r=tsp();
/*for(int i=0;i<tam;i++){
for(int j=0;j<(1<<tam);j++){
cout<<dp[i][j]<<" ";
}
cout<<endl;
}*/
return r;
}
Compilation message (stderr)
# | 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... |