Submission #948495

#TimeUsernameProblemLanguageResultExecution timeMemory
948495phone64bitCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
101 ms16068 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN = 1e5+10; struct Q { int src; ll w; bool operator < (const Q&rhs) const { return w>rhs.w; } }; struct path { int dest; ll w; }; vector<path> edges[mxN]; ll dp[mxN], ans = 1e18; priority_queue<Q> pq; int main() { for(int i=0; i<mxN; i++) dp[i]=1e18; int n,m,s,t,u,v; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v); while(m--) { int u, v; ll w; scanf("%d%d%lld", &u, &v, &w); edges[u].push_back({v, w}); edges[v].push_back({u, w}); } dp[u] = 0; pq.push({u, 0}); while(!pq.empty()) { auto [src, w] = pq.top(); pq.pop(); if(src==v) { ans=w; break; } for(auto v: edges[src]) { if(dp[v.dest]>w+v.w) { dp[v.dest]=w+v.w; pq.push({v.dest, dp[v.dest]}); } } } printf("%lld", ans); return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:25:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     int n,m,s,t,u,v; scanf("%d%d%d%d%d%d", &n,&m,&s,&t,&u,&v);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:27:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         int u, v; ll w; scanf("%d%d%lld", &u, &v, &w);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...