forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassy.cpp
68 lines (60 loc) · 1.53 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
void parse(string rank, string name, string& parsedRank) {
for(int i = 0; i < rank.length(); i++) {
if(rank[i] == 'u') {
parsedRank += 'a';
}
if(rank[i] == 'm') {
parsedRank += 'b';
}
if(rank[i] == 'o') {
parsedRank += 'c';
}
}
int l = parsedRank.length();
for(int j = 0; j < l/2; j++) {
swap(parsedRank[j], parsedRank[l-j-1]);
}
while(l < 10) {
l++;
parsedRank += 'b';
}
parsedRank += ' ';
parsedRank += name;
parsedRank.pop_back();
}
void print(vector<string> names) {
for(int i = 0; i < names.size(); i++) {
bool space = false;
for(int j = 0; j < names[i].size(); j++) {
if(space) {
cout << names[i][j];
}
else if(names[i][j] == ' ') {
space = true;
}
}
cout << endl;
}
cout << "==============================" << endl;
}
int main() {
int cases = 0, nameNum = 0;
cin >> cases;
for(int i = 0; i < cases; i++) {
cin >> nameNum;
vector<string> names;
for(int j = 0; j < nameNum; j++) {
string name, rank, parsedRank = "", garbage;
cin >> name >> rank >> garbage;
parse(rank, name, parsedRank);
names.push_back(parsedRank);
}
sort(names.begin(), names.end());
print(names);
}
}