Submission #491564

#TimeUsernameProblemLanguageResultExecution timeMemory
491564stefantagaToll (BOI17_toll)C++14
0 / 100
3061 ms6632 KiB
#include <bits/stdc++.h> #define INF 1000000000 using namespace std; int k,n,m,o,a,b,din[50005],minim; vector <pair <int,int>> v[50005]; void dfs(int x,int query,int cost) { if (x/k>query/k) { return; } if (x==query) { minim=min(minim,query); } for (int i=0;i<v[x].size();i++) { dfs(v[x][i].first,query,v[x][i].second+cost); } } int i; int main() { #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>k>>n>>m>>o; for (i=1;i<=m;i++) { int x,y,cost; cin>>x>>y>>cost; v[x].push_back({y,cost}); } for (i=1;i<=o;i++) { cin>>a>>b; minim = INF; dfs(a,b,0); if (minim==INF) { cout<<"-1"<<'\n'; } else cout<<minim<<'\n'; } return 0; }

Compilation message (stderr)

toll.cpp: In function 'void dfs(int, int, int)':
toll.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i=0;i<v[x].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...
#Verdict Execution timeMemoryGrader output
Fetching results...