제출 #272975

#제출 시각아이디문제언어결과실행 시간메모리
272975ggoorooRoller Coaster Railroad (IOI16_railroad)C++14
34 / 100
906 ms33288 KiB
#include "railroad.h" #include<cstdio> #include<iostream> #include<queue> #define N 200005 using namespace std; typedef long long ll; ll n, s[N], mn[20][66000], l[N], u[N]; bool v[20][66000]; struct st { ll c1, c2, w; }; bool operator < (st p, st q) { return p.w > q.w; } priority_queue<st> qu; void pu(ll p, ll q, ll z) { if (v[p][q] && mn[p][q] <= z) return; v[p][q] = 1; mn[p][q] = z; qu.push({p, q, z}); } long long plan_roller_coaster(std::vector<int> lll, std::vector<int> uu) { ll i, pl; st t; n = lll.size(); for (i = 0; i <n; i++) { l[i] = lll[i]; u[i] = uu[i]; } s[0] = 1; for (i = 1; i <= n; i++) { s[i] = s[i - 1] * 2; } for (i = 0; i < n; i++) { pu(i, s[i], 0); } while (!qu.empty()) { t = qu.top(); qu.pop(); if (t.c2 == s[n] - 1) return t.w; for (i =0; i < n; i++) { if ((t.c2 & s[i]) != 0) continue; pl = 0; if (u[t.c1] > l[i]) pl = u[t.c1] - l[i]; pu(i, t.c2 + s[i], t.w + pl); } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...