Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = (int) 1e6 + 10;
- class Person {
- public:
- int type;
- int score;
- string name;
- Person() {}
- Person(string name, int score, int type) {
- this -> name = name;
- this -> type = type;
- this -> score = score;
- }
- };
- int main ()
- {
- ios_base::sync_with_stdio(false);
- int n, m;
- cin >> n >> m;
- array <Person*, N> people;
- for (int i = 0; i < n; ++i) {
- string name;
- int score, type;
- cin >> name >> type >> score;
- people[i] = new Person(name, score, type);
- }
- sort(people.begin(), people.begin() + n, [](auto x, auto y) {
- if(x -> type != y -> type) return x -> type < y -> type;
- else return x -> score > y -> score;
- });
- auto solve = [n](auto arr) {
- int temp = 1;
- arr[n] = new Person("Magneet", -228, -322);
- arr[n + 1] = new Person("GG", -229, -323);
- for(int i = 0; i < n; ++i) {
- if(temp == arr[i] -> type) {
- if(arr[i] -> score != arr[i + 1] -> score) {
- if(arr[i + 1] -> type != arr[i + 2] -> type)
- cout << arr[i] -> name << ' ' << arr[i + 1] -> name << endl;
- else if(arr[i + 1] -> score != arr[i + 2] -> score)
- cout << arr[i] -> name << ' ' << arr[i + 1] -> name << endl;
- else
- cout << '?' << endl;
- } else {
- cout << '?' << endl;
- }
- temp++;
- }
- }
- };
- solve(people);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement