Submission #472497

#TimeUsernameProblemLanguageResultExecution timeMemory
472497ZaZo_Toll (BOI17_toll)C++14
0 / 100
3084 ms3244 KiB
#include <bits/stdc++.h> #define ZAZO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); //#define int long long using namespace std; vector<pair<int,int>>edges[50001]; int k , n , m , o ; int djk(int s , int e) { int dist[n+1]; for(int i = 0 ; i < n+1 ; i ++) dist[i]=1e15; priority_queue<pair<int,int>>pq; dist[s]=0; pq.push({0,s}); while(!pq.empty()) { int c = -pq.top().first , u = pq.top().second; pq.pop(); for(int i = 0 ; i < edges[u].size() ; i++) { if(dist[edges[u][i].first] > edges[u][i].second + c) { dist[edges[u][i].first] = edges[u][i].second+c; // cout<<dist[edges[u][i].first]<<endl; pq.push({-dist[edges[u][i].first],edges[u][i].first}); } } } return dist[e]; } int32_t main() { ZAZO cin >> k >> n >> m >> o ; for(int i = 0 ; i < m ; i ++) { int a , b , t; cin >> a >> b >> t; edges[a].push_back({b,t}); } while(o--) { int a , b; cin >> a >> b; int ans=djk(a,b); if(ans==1e15) cout<<"-1"<<endl; else cout<<ans<<endl; } }

Compilation message (stderr)

toll.cpp: In function 'int djk(int, int)':
toll.cpp:10:43: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+15' to '2147483647' [-Woverflow]
   10 |   for(int i = 0 ; i < n+1 ; i ++) dist[i]=1e15;
      |                                           ^~~~
toll.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 0 ; i < edges[u].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...