Submission #968752

#TimeUsernameProblemLanguageResultExecution timeMemory
968752tamir1Evacuation plan (IZhO18_plan)C++17
23 / 100
357 ms48056 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; ll n,m,k,i,x,y,z,q,dis[100005]; bitset<100005> vis; vector<pair<ll,ll>> v[100005]; priority_queue<pair<ll,ll>> a; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m; for(i=1;i<=m;i++){ cin >> x >> y >> z; v[x].push_back({y,z}); v[y].push_back({x,z}); } cin >> k; for(i=1;i<=k;i++){ cin >> x; a.push({0,x}); } while(!a.empty()){ z=a.top().ff; x=a.top().ss; a.pop(); if(vis[x]) continue; vis[x]=1; dis[x]=-z; for(pair<ll,ll> i:v[x]){ if(!vis[i.ff]) a.push({z-i.ss,i.ff}); } } cin >> q; for(i=1;i<=q;i++){ cin >> x >> y; cout << min(dis[x],dis[y]) << "\n"; } }
#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...