Submission #1108151

#TimeUsernameProblemLanguageResultExecution timeMemory
1108151KasymKEvacuation plan (IZhO18_plan)C++17
23 / 100
310 ms29480 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 1e5+5; const ll INF = 1e18; vector<pii> adj[N]; ll dis[N]; int main(){ int n, m; scanf("%d%d", &n, &m); for(int i = 1; i <= m; ++i){ int a, b, c; scanf("%d%d%d", &a, &b, &c); adj[a].pb({b, c}); adj[b].pb({a, c}); } for(int i = 0; i <= n; ++i) dis[i] = INF; int k; scanf("%d", &k); priority_queue<pli, vector<pli>, greater<pli>> pq; for(int i = 1; i <= k; ++i){ int x; scanf("%d", &x); pq.push({0, x}); dis[x] = 0; } while(!pq.empty()){ int x = pq.top().ss; ll val = pq.top().ff; pq.pop(); if(dis[x] != val) continue; tr(it, adj[x]){ int a = it->ff, w = it->ss; if(umin(dis[a], dis[x]+w)) pq.push({dis[a], a}); } } int q; scanf("%d", &q); while(q--){ int s, t; scanf("%d%d", &s, &t); printf("%lld\n", min(dis[s], dis[t])); } return 0; }

Compilation message (stderr)

plan.cpp: In function 'int main()':
plan.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
plan.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d%d%d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plan.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d", &k);
      |     ~~~~~^~~~~~~~~~
plan.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
plan.cpp:53:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
plan.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         scanf("%d%d", &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...
#Verdict Execution timeMemoryGrader output
Fetching results...