Submission #565781

#TimeUsernameProblemLanguageResultExecution timeMemory
565781AbdullahMWEvacuation plan (IZhO18_plan)C++14
23 / 100
750 ms53940 KiB
#include <bits/stdc++.h> #define all(vec) vec.begin(), vec.end() #define ll long long #define db double #define pb push_back #define pf push_front #define newl "\n" #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define f first #define s second #define MOD 1000000007 using namespace std; vector <pair <ll, ll>> gr[100005]; unordered_map <ll, ll> fin, dist; unordered_map <ll, bool> nuc; priority_queue <pair <ll, ll>, vector <pair <ll, ll>>, greater <pair <ll, ll>>> pq; void near() { unordered_map <ll, bool> vis; while (pq.size()) { ll c = pq.top().s, len = pq.top().f; pq.pop(); if (!vis[c]) { fin[c] = min(fin[c], len); vis[c] = true; for (auto v : gr[c]) { pq.push({len + v.f, v.s}); } } } } ll dj(ll beg, ll nd) { priority_queue <pair <ll, ll>> d; unordered_map <ll, bool> vis; d.push({fin[beg], beg}); while (d.size()) { ll c = d.top().s, len = d.top().f; d.pop(); if (!vis[c]) { if (c == nd) return len; vis[c] = true; for (auto v : gr[c]) { d.push({min(len, fin[v.s]), v.s}); } } } } int main() { fast //setIO(""); //freopen("filename.in", "r", stdin); //freopen("filename.out", "w", stdout); ll n, m; cin >> n >> m; for (ll i = 1; i <= m; i++) { ll x, y, len; cin >> x >> y >> len; gr[x].pb({len, y}); gr[y].pb({len, x}); } ll k; cin >> k; for (ll i = 1; i <= k; i++) { ll idx; cin >> idx; nuc[idx] = true; } for (ll i = 1; i <= n; i++) { if (nuc[i]) { pq.push({0, i}); } else { fin[i] = 1e18; } } near(); //cout << newl; ll q; cin >> q; while (q--) { ll x, y; cin >> x >> y; cout << min(fin[x], fin[y]) << newl; } /*cout << newl; for (ll i = 1; i <= n; i++) { if (!nuc[i]) cout << "City: " << i << " Dist: " << fin[i] << newl; }*/ }

Compilation message (stderr)

plan.cpp: In function 'long long int dj(long long int, long long int)':
plan.cpp:44:36: warning: control reaches end of non-void function [-Wreturn-type]
   44 |     priority_queue <pair <ll, ll>> d;
      |                                    ^
#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...