Submission #69364

#TimeUsernameProblemLanguageResultExecution timeMemory
69364hamzqq9Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
149 ms8764 KiB
#include "railroad.h" #include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 200000000000000000 #define MOD 1000000007 #define N 755 #define MAX 10000006 #define LOG 30 #define KOK 200 using namespace std; ll full; bool vis[16][pw(16)]; ll dp[16][pw(16)]; vector<ii> v[16]; ll S3(vector<int>&s, vector<int>& t) { return 0; } ll solve(int now,int mask) { if(vis[now][mask]) return dp[now][mask]; if(mask==full) return 0; vis[now][mask]=1; ll& r=dp[now][mask]; r=inf; for(int i=0;i<sz(v[now]);i++) { if(mask&pw(v[now][i].nd)) continue ; umin(r,solve(v[now][i].nd,mask|pw(v[now][i].nd))+v[now][i].st); } return r; } ll S12(vector<int>&s, vector<int>& t) { for(int i=0;i<sz(s);i++) { for(int j=0;j<sz(s);j++) { if(i==j) continue ; v[i].pb({max(0,t[i]-s[j]),j}); } } full=pw(sz(s))-1; ll ans=inf; for(int i=0;i<sz(s);i++) { umin(ans,solve(i,pw(i))); } return ans; } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { if(sz(s)<=16) return S12(s,t); else return S3(s,t); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...