Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- map <string,pair<string,int>> M;
- list<pair<string,string>> kruna(map <string,pair<string,int>> M) {
- list <pair<string,string>> ret;
- for(auto it = M.begin(); it != M.end(); it++) {
- //cout << it->second.first << " " << M[it->second.first].first << endl;
- if(M[it->second.first].first != "") {
- auto l = ret.begin();
- int flag = 0;
- for(;l != ret.end(); l++) {
- if((*l).first == M[it->second.first].first) {
- flag = 1;
- if(M[l->second].second < it->second.second) {
- l->second = it->first;
- }
- }
- }
- if(!flag) {
- ret.push_back(make_pair(M[it->second.first].first,it->first));
- }
- }
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement