Submission #994841

#TimeUsernameProblemLanguageResultExecution timeMemory
994841SuPythonyRoller Coaster Railroad (IOI16_railroad)C++17
11 / 100
2094 ms524288 KiB
#include <bits/stdc++.h> #include "railroad.h" using namespace std; typedef long long ll; vector<vector<pair<int,ll>>> al; vector<int> vis; ll c; int n; int tot; ll mn=1e18; void dfs(int u) { vis[u]=1; n++; if (n==tot) { mn=min(mn,c); } for (auto i: al[u]) { if (vis[i.first]) continue; c+=i.second; dfs(i.first); c-=i.second; } vis[u]=0; n--; } ll plan_roller_coaster(vector<int> s, vector<int> t) { al.assign(s.size(),vector<pair<int,ll>>()); tot=s.size(); for (int i=0; i<s.size(); i++) { for (int j=0; j<s.size(); j++) { if (i==j) continue; ll w=0; if (t[i]>s[j]) w=t[i]-s[j]; al[i].push_back({j,w}); } } mn=1e18; for (int i=0; i<s.size(); i++) { vis.assign(s.size(),0); c=0; n=0; dfs(i); } return mn; };

Compilation message (stderr)

railroad.cpp: In function 'll plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0; i<s.size(); i++) {
      |                   ~^~~~~~~~~
railroad.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j=0; j<s.size(); j++) {
      |                       ~^~~~~~~~~
railroad.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i=0; i<s.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...