Submission #100023

#TimeUsernameProblemLanguageResultExecution timeMemory
100023owl10124Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
149 ms26536 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; typedef long long ll; typedef pair<int,int> ii; vector<ii> segs; int n; ll m[16][65536]; ll dp(int seg, int bm) { if (bm==(1<<n)-1) return m[seg][bm]=0; if (seg!=-1&&m[seg][bm]!=-1) return m[seg][bm]; ll l = 1ll<<60; for (int i=0;i<n;i++) { if (((1<<i)&~bm)) l=min(l,(seg!=-1&&segs[seg].second>segs[i].first?segs[seg].second-segs[i].first:0)+dp(i,bm|(1<<i))); } //printf("%d %d %d %lld\n",segs[seg].second,seg,bm,l); return (seg!=-1 ? m[seg][bm]=l : l); } ll plan_roller_coaster(std::vector<int> s, std::vector<int> t) { fill(&m[0][0],&m[16][0],-1); n = (int) s.size(); for (int i=0;i<n;i++) segs.push_back(make_pair(s[i],t[i])); return dp(-1,0); }

Compilation message (stderr)

railroad.cpp: In function 'll plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:14:35: warning: array subscript is below array bounds [-Warray-bounds]
     if (bm==(1<<n)-1) return m[seg][bm]=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...