Advertisement
ahmed_aly

C++ solution for problem B

Apr 13th, 2011
2,555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <cstring>
  2. #include <map>
  3. #include <deque>
  4. #include <queue>
  5. #include <stack>
  6. #include <sstream>
  7. #include <iostream>
  8. #include <iomanip>
  9. #include <cstdio>
  10. #include <cmath>
  11. #include <cstdlib>
  12. #include <ctime>
  13. #include <algorithm>
  14. #include <vector>
  15. #include <set>
  16. #include <complex>
  17. #include <list>
  18. #include <climits>
  19. #include <cctype>
  20.  
  21. using namespace std;
  22.  
  23. int main() {
  24.     string myName;
  25.     cin >> myName;
  26.     int n;
  27.     cin >> n;
  28.     map<string, int> factor;
  29.     string name1, action, temp, name2;
  30.     for (int i = 0; i < n; i++) {
  31.         cin >> name1;
  32.         cin >> action;
  33.         if (action == "posted" || action == "commented")
  34.             cin >> temp;
  35.         cin >> name2;
  36.         name2 = name2.substr(0, name2.length() - 2);
  37.         cin >> temp;
  38.         int val = 5;
  39.         if (action == "posted")
  40.             val = 15;
  41.         else if (action == "commented")
  42.             val = 10;
  43.         if (name1 == myName)
  44.             factor[name2] += val;
  45.         else
  46.             factor[name1];
  47.         if (name2 == myName)
  48.             factor[name1] += val;
  49.         else
  50.             factor[name2];
  51.     }
  52.     vector<pair<int, string> > ret;
  53.     for (map<string, int>::iterator it = factor.begin(); it != factor.end(); it++)
  54.         ret.push_back(make_pair(-it->second, it->first));
  55.     sort(ret.begin(), ret.end());
  56.     int m = ret.size();
  57.     for (int i = 0; i < m; i++)
  58.         cout << ret[i].second << endl;
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement