Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
705 B
1
Indexable
Never
#include<bits/stdc++.h>

using namespace std;
int main(){
    priority_queue<pair<int,pair<string,string>>,vector<pair<int,pair<string,string>>>, greater<pair<int,pair<string,string>>>>pq;
    int a,b;
    cout<<"edges: ";
    cin>>a;cout<<"nodes: ";
    cin>>b;
    for(int i=0;i<a;i++){
        int a;
        string b,c;
        cout<<"Weight: ";
        cin>>a;
        cout<<"start from: ";
        cin>>b;
        cout<<"Ends at: ";
        cin>>c;

        pq.push({a,{b,c}});
    }
    while(!pq.empty()){
        pair<int, pair<string,string>> t=pq.top();
        pq.pop();
        cout<<t.second.first<<'\t'<<t.second.second<<'\t'<<t.first<<endl;
    }

return 0;
}