Advertisement
in_chainz

Untitled

Jan 26th, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <utility>
  4. #include <string>
  5. #include <vector>
  6. #include <tuple>
  7.  
  8. struct Student {
  9.     uint32_t score, day, mon, year;
  10.     std::string name, surname;
  11.     std::vector<std::string> univ;
  12.     Student(const std::string &_name, const std::string &_surname,
  13.             uint32_t _day, uint32_t _mon, uint32_t _year,
  14.             uint32_t _score)
  15.             : name(_name),
  16.               surname(_surname),
  17.               day(_day),
  18.               mon(_mon),
  19.               year(_year),
  20.               score(_score) {}
  21. };
  22.  
  23. int main() {
  24.  
  25.     std::vector<Student> st;
  26.     std::map<std::string, std::pair<int, std::vector<std::string>>> universities;
  27.  
  28.     uint32_t n;
  29.     std::cin >> n;
  30.     for (uint32_t i = 0; i < n; ++i) {
  31.         std::string name;
  32.         uint32_t thresh;
  33.         std::cin >> name >> thresh;
  34.         universities[name] = {thresh, std::vector<std::string>()};
  35.     }
  36.  
  37.     uint32_t m;
  38.     std::cin >> m;
  39.     st.reserve(m);
  40.     for (uint32_t i = 0; i < m; ++i) {
  41.         uint32_t day, mon, year, score, k;
  42.         std::vector<std::string> univ;
  43.         std::string name, surname;
  44.         std::cin >> name >> surname >> day >> mon >>
  45.                  year >> score >> k;
  46.         st.emplace_back(name, surname, day, mon, year, score);
  47.         st[i].univ.reserve(k);
  48.         for (uint32_t j = 0; j < k; ++j) {
  49.             std::string wish;
  50.             std::cin >> wish;
  51.             st[i].univ.emplace_back(wish);
  52.         }
  53.     }
  54.     sort(st.begin(), st.end(), [](const Student &a, const Student &b) {
  55.         return std::tie(-a.score, a.year, a.mon, a.day, a.name, a.surname) <
  56.                 std::tie(-b.score, b.year, b.mon, b.day, b.name, b.surname);
  57.     });
  58.  
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement