Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define ld long double
- #define pb push_back
- #define p_b pop_back
- using namespace std;
- struct jersey{
- string name;
- string color;
- string size;
- };
- int comp(string a, string b){
- if(a == "P" && (b == "M" || b == "G")){
- return 0;
- } else if(a == "M" && b == "G"){
- return 0;
- } else if(a == b){
- return 2;
- } else{
- return 1;
- }
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int flag = 0;
- while(true){
- int n;
- cin >> n;
- if(n == 0){
- break;
- }
- if(flag == 1){
- cout << "\n";
- }
- vector<jersey> v;
- for(int i = 0; i < n; i++){
- cin.ignore(1, '\n');
- jersey x;
- getline(cin, x.name);
- cin >> x.color >> x.size;
- v.pb(x);
- }
- for(int i = 1; i < n; i++){
- for(int j = 0; j < n-i; j++){
- if(v[j].color > v[j+1].color){
- swap(v[j], v[j+1]);
- } else if(v[j].color == v[j+1].color){
- if(comp(v[j].size, v[j+1].size) == 1){
- swap(v[j], v[j+1]);
- } else if(comp(v[j].size, v[j+1].size) == 2){
- if(v[j].name > v[j+1].name){
- swap(v[j], v[j+1]);
- }
- }
- }
- }
- }
- for(int i = 0; i < n; i++){
- cout << v[i].color << " " << v[i].size << " " << v[i].name << "\n";
- }
- flag = 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement