-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclassy.cpp
51 lines (49 loc) · 1.1 KB
/
classy.cpp
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
#include <bits/stdc++.h>
using namespace std;
bool comparator(pair<string, string> a, pair<string, string> b) {
auto [al, an] = a;
auto [bl, bn] = b;
if (al < bl) {
return false;
}
if (al > bl) {
return true;
}
if (an < bn) {
return true;
}
if (an > bn) {
return false;
}
return false;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<pair<string, string>> data;
for (int i = 0; i < n; i++) {
string name, level, cls;
cin >> name >> level >> cls;
name.pop_back();
level = regex_replace(level, regex("upper"), "3");
level = regex_replace(level, regex("middle"), "2");
level = regex_replace(level, regex("lower"), "1");
reverse(level.begin(), level.end());
while (level.size() < 20) {
level += "-2";
}
data.push_back({level, name});
}
sort(data.begin(), data.end(), comparator);
for (auto [level, name]: data) {
cout << name << endl;
}
cout << "==============================" << endl;
}
return 0;
}