Advertisement
elica123

Untitled

Apr 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. map <string,pair<string,int>> M;
  5.  
  6. list<pair<string,string>> kruna(map <string,pair<string,int>> M) {
  7. list <pair<string,string>> ret;
  8.  
  9. for(auto it = M.begin(); it != M.end(); it++) {
  10. //cout << it->second.first << " " << M[it->second.first].first << endl;
  11. if(M[it->second.first].first != "") {
  12. auto l = ret.begin();
  13. int flag = 0;
  14. for(;l != ret.end(); l++) {
  15. if((*l).first == M[it->second.first].first) {
  16. flag = 1;
  17. if(M[l->second].second < it->second.second) {
  18. l->second = it->first;
  19. }
  20. }
  21. }
  22. if(!flag) {
  23. ret.push_back(make_pair(M[it->second.first].first,it->first));
  24. }
  25. }
  26. }
  27. return ret;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement