UVA 10986 Solution - Sending email
UVA 10986 Solution - Sending email uva id: shoaib05 Accepted Time: 0.379 I used priority queue and Dijkstra Algorithm. Code: #include<iostream> #include<vector> #include<algorithm> #include<map> #include<queue> #include<cstring> using namespace std; typedef pair<int,int> pii; typedef vector<pii> vecpii; map<int,vecpii> mymap; map<int,int> result; bool visit[20010]; class Compare { public: bool operator()(pii p1,pii p2) { return p1.second>p2.second; } }; int DjKastra(int x,int y) { priority_queue<pii,vector<pii>,Compare> q; pii p,temp; int i; memset(visit,false,sizeof(visit)); q.push(pii(x,0)); while(!q.empty()) { p=q.top(); if(p.first==y) return p.second; q.pop(); if(visit[p.first]) continue; visit[p.first]=true; for(i=0;i<mymap[p.first].size();i++) { temp=mymap[p.first][i]; if(!visit[temp.first]) { q.push(pi...