-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path210201_B0J_10814.cpp
More file actions
91 lines (80 loc) · 1.57 KB
/
Copy path210201_B0J_10814.cpp
File metadata and controls
91 lines (80 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
if (a.first > b.first) {
return false;
}
else if (a.first < b.first) {
return true;
}
else {
if (a.second > b.second) {
return false;
}
else
return true;
}
}
int N = 0;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> N;
vector<pair<int, int>> v(N);
vector<string> s(N);
for (int i = 0; i < N; ++i) {
int a; string b;
cin >> a >> b;
v[i].first = a;
v[i].second = i;
s[i] = b;
}
sort(v.begin(), v.end(), cmp);
for (int i = 0; i < v.size(); ++i) {
cout << v[i].first << " " << s[v[i].second] << "\n";
}
return 0;
}
//struct cmp {
// bool operator()(const pair<pair<int, string>, int> &a, const pair<pair<int, string>, int> &b) {
// if (a.first.first > b.first.first) {
// return true;
// }
// else if (a.first.first < b.first.first) {
// return false;
// }
// else {
// if (a.second > b.second) {
// return true;
// }
// else
// return false;
// }
// }
//};
//
//int main() {
//
// ios::sync_with_stdio(false);
// cin.tie(NULL);
//
// cin >> N;
// priority_queue<pair<pair<int, string>, int>, vector<pair<pair<int, string>, int>>, cmp> pq;
//
// for (int i = 0; i < N; ++i) {
// pair<pair<int, string>, int> temp;
// cin >> temp.first.first >> temp.first.second;
// temp.second = i + 1;
// pq.push(temp);
// }
//
// while (!pq.empty()) {
// cout << pq.top().first.first << " " << pq.top().first.second << "\n";
// pq.pop();
// }
//
// return 0;
//}