Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- struct Student {
- int id, d, m, y, score, unik_n;
- string name, surname;
- vector<string> u;
- };
- void solve() {
- int n;
- cin >> n;
- map<string, pair<int, vector<int>>> unik;
- for (int i = 0; i < n; i++) {
- string name;
- int places;
- cin >> name >> places;
- unik[name].first = places;
- }
- int m;
- cin >> m;
- vector<Student> a(m);
- for (int i = 0; i < m; i++) {
- a[i].id = i;
- cin >> a[i].name >> a[i].surname
- >> a[i].d >> a[i].m >> a[i].y
- >> a[i].score >> a[i].unik_n;
- for (int j = 0; j < a[i].unik_n; j++) {
- string s;
- cin >> s;
- a[i].u.push_back(s);
- }
- }
- sort(a.begin(), a.end(), [] (auto& a, auto& b) {
- return tie(b.score, a.y, a.m, a.d, a.surname, a.name) <
- tie(a.score, b.y, b.m, b.d, b.surname, b.name);
- });
- for (int i = 0; i < m; i++) {
- for (auto &un : a[i].u) {
- if (unik[un].first > 0) {
- unik[un].second.push_back(i);
- unik[un].first--;
- break;
- }
- }
- }
- for (auto [name, data] : unik) {
- sort(data.second.begin(), data.second.end(), [&a] (auto firstIndex, auto secondIndex) {
- const auto& first = a[firstIndex];
- const auto& second = a[secondIndex];
- return tie(first.surname, first.name, first.y, first.m, first.d) <
- tie(second.surname, second.name, second.y, second.m, second.d);
- });
- cout << name << '\t';
- for (auto& i : data.second) {
- cout << a[i].name << ' ' << a[i].surname << '\t';
- }
- cout << '\n';
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement