Submission #241202

#TimeUsernameProblemLanguageResultExecution timeMemory
241202crossing0verRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
542 ms131704 KiB
#include<bits/stdc++.h> /*#pragma GCC optimize("03") #pragma GCC target("avx,avx2") #pragma GCC optimeze("unroll-loops") */ #define inf 10000000000000000 #define ll long long #include "railroad.h" using namespace std; int n; ll dp[16][16][1 << 16],cost[16][16]; ll small_case(vector<int> a,vector<int> b) { n = a.size(); for (int i = 0; i < n; i++) { for (int j = 0;j < n; j++) { if (b[i] > a[j] && j != i) cost[i][j] = b[i] - a[j]; fill(dp[i][j],dp[i][j] + (1 << n),inf); } dp[i][i][(1 << i)] = 0; } for (int mask = 1; mask < (1 << n); mask++) for (int i = 0; i < n; i++) { if ((1 << i) & mask) { for (int j = 0; j < n; j++) { if ( ((1 << j) & mask) && j != i) { for (int e = 0; e < n; e++) { if (e != j && dp[i][j][mask] > dp[i][e][mask^(1<<j)] + cost[e][j]) dp[i][j][mask] = dp[i][e][mask^(1<<j)] + cost[e][j]; } } } } } ll ans = inf; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans = min(ans,dp[i][j][(1<<n)-1]); return ans; } ll plan_roller_coaster(vector<int> a, vector<int> b) { n = a.size(); if (n <= 16) return small_case(a,b); }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...