Untitled

 avatar
unknown
plain_text
2 years ago
496 B
8
Indexable
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, e;
    cin >> n >> e;
    priority_queue<pair<int,pair<char,char>>, vector<pair<int,pair<char,char>>>, greater<pair<int,pair<char,char>>>>pq;
    for(int i=0; i<e; i++){
        char a, b; int c;
        cin >> a  >> b >> c;
        pq.push({c, {a,b}});}
    while(!pq.empty()){
        cout << pq.top().second.first << ", " << pq.top().second.second << ", " << pq.top().first << endl;
        pq.pop();
    }}
Editor is loading...