-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathP24730_ca_Parvulari.cc
More file actions
35 lines (33 loc) · 916 Bytes
/
Copy pathP24730_ca_Parvulari.cc
File metadata and controls
35 lines (33 loc) · 916 Bytes
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
#include <bits/stdc++.h>
using namespace std;
struct Profesor {
string nom;
int caramels, pastanagues;
friend istream& operator>> (istream& in, Profesor& p) {
in >> p.nom >> p.caramels >> p.pastanagues;
return in;
}
bool operator< (const Profesor& p) {
if (p.caramels == caramels) {
if (p.pastanagues == pastanagues) {
if (p.nom.size() == nom.size()) return nom < p.nom;
return nom.size() < p.nom.size();
}
return pastanagues > p.pastanagues;
}
return caramels > p.caramels;
}
};
int main () {
int n;
cin >> n;
while (n--) {
int p;
cin >> p;
vector <Profesor> v (p);
for (size_t i = 0; i < v.size(); ++i) cin >> v[i];
sort(v.begin(), v.end());
for (auto profe : v) cout << profe.nom << endl;
cout << endl;
}
}