Submission #140458

#TimeUsernameProblemLanguageResultExecution timeMemory
140458bazsi700Roller Coaster Railroad (IOI16_railroad)C++14
0 / 100
195 ms152824 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; #define MOD 1000000007 #define ll long long int #define vi vector<int> #define vii vector< vector<int> > #define PI 3.1415926535897932384626433832795 #define INF 9223372036854775807LL #define hashA 1257958787 #define hashB 1539500609 #define endl "\n" ll dp[17][17][66000]; ll plan_roller_coaster(vector<int> s, vector<int> t) { int n = s.size(); for(int i = 0; i < 17; i++) { for(int k = 0; k < 17; k++) { for(int j = 0; j < 66000; j++) { dp[i][k][j] = INF; } } } if(n <= 16) { for(int i = 0; i < n; i++) { dp[1][i][(1<<i)] = 0; } for(int i = 2; i <= n; i++) { for(int lst = 0; lst < n; lst++) { for(int mask = 0; mask < (1<<n); mask++) { if((mask&(1<<lst)) == 0) { continue; } vector<int> setbits; for(int k = 0; k < n; k++) { if(mask&(1<<k)) { setbits.push_back(k); } } if(setbits.size() != i) { continue; } for(int k : setbits) { int oldmask = mask^(1<<k); for(int l : setbits) { if(l != k && l != lst) { dp[i][lst][mask] = min(dp[i][lst][mask],dp[i-1][l][oldmask]+max(0,t[l]-s[lst])); } } } } } } ll ans = INF; for(int lst = 0; lst < n; lst++) { ans = min(ans,dp[n][lst][(1<<n)-1]); } return ans; } return 0; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:42:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      if(setbits.size() != i) {
         ~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...