Advertisement
Ne-Biolog

Untitled

Jun 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = (int) 1e6 + 10;
  6.  
  7. class Person {
  8. public:
  9. int type;
  10. int score;
  11. string name;
  12.  
  13. Person() {}
  14. Person(string name, int score, int type) {
  15. this -> name = name;
  16. this -> type = type;
  17. this -> score = score;
  18. }
  19. };
  20.  
  21. int main ()
  22. {
  23. ios_base::sync_with_stdio(false);
  24.  
  25. int n, m;
  26. cin >> n >> m;
  27. array <Person*, N> people;
  28.  
  29. for (int i = 0; i < n; ++i) {
  30. string name;
  31. int score, type;
  32. cin >> name >> type >> score;
  33. people[i] = new Person(name, score, type);
  34. }
  35.  
  36. sort(people.begin(), people.begin() + n, [](auto x, auto y) {
  37. if(x -> type != y -> type) return x -> type < y -> type;
  38. else return x -> score > y -> score;
  39. });
  40.  
  41. auto solve = [n](auto arr) {
  42. int temp = 1;
  43. arr[n] = new Person("Magneet", -228, -322);
  44. arr[n + 1] = new Person("GG", -229, -323);
  45. for(int i = 0; i < n; ++i) {
  46. if(temp == arr[i] -> type) {
  47. if(arr[i] -> score != arr[i + 1] -> score) {
  48. if(arr[i + 1] -> type != arr[i + 2] -> type)
  49. cout << arr[i] -> name << ' ' << arr[i + 1] -> name << endl;
  50. else if(arr[i + 1] -> score != arr[i + 2] -> score)
  51. cout << arr[i] -> name << ' ' << arr[i + 1] -> name << endl;
  52. else
  53. cout << '?' << endl;
  54. } else {
  55. cout << '?' << endl;
  56. }
  57. temp++;
  58. }
  59. }
  60. };
  61.  
  62. solve(people);
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement