Submission #1025062

#TimeUsernameProblemLanguageResultExecution timeMemory
10250620npataRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
33 ms10580 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; #define vec vector #define int long long const int MXN = 16; const int INF = 1e18; int dist[MXN][MXN]; int dp[MXN][MXN][(1<<MXN) + 1]; long long plan_roller_coaster(std::vector<int32_t> s, std::vector<int32_t> t) { int n = s.size(); for(int i = 0; i<n; i++) { for(int j = 0; j<n; j++) { if(i==j) continue; dist[i][j] = max(t[i]-s[j], 0); } } for(int i = 0; i<(1<<n); i++) { for(int j = 0; j<n; j++) { for(int k = 0; k<n; k++) { dp[j][k][i] = INF; } } } for(int i = 0; i<n; i++) { dp[i][i][1<<i] = 0; } for(int i = 0; i<(1<<n); i++) { for(int j = 0; j<n; j++) { if((1<<j) & i != 0) continue; for(int k = 0; k<n; k++) { if((1<<k) & i == 0) continue; for(int l = 0; l<n; l++) { if((1<<l) & i == 0) continue; dp[j][k][i | (1<<j)] = min(dp[j][k][i | (1<<j)], dp[l][k][i] + dist[l][j]); } } } } int ans = INF; for(int i = 0; i<n; i++) { for(int j = 0; j<n; j++) { if(i == j) continue; //cerr << dp[i][j][(1<<n)-1] << ' '; ans = min(ans, dp[i][j][(1<<n)-1]); } } // cerr << '\n'; // cerr << ans << '\n'; return ans; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:42:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   42 |    if((1<<j) & i != 0) continue;
      |                ~~^~~~
railroad.cpp:44:19: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   44 |     if((1<<k) & i == 0) continue;
      |                 ~~^~~~
railroad.cpp:46:20: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   46 |      if((1<<l) & i == 0) continue;
      |                  ~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...