Submission #136633

#TimeUsernameProblemLanguageResultExecution timeMemory
136633DanerZeinRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
245 ms165352 KiB
#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)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:34:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i++){
               ~^~~~~~~~~
railroad.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=i+1;j<s.size();j++){
                   ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...