#include <iostream>
#include <vector>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin>>n){
vector<pair<vector<int>,string> > a(n,make_pair(vector<int>(3),""));
for(int i=0;i<n;i++){
ws(cin);
string s;
cin>>a[i].second;
cin>>s;
cin>>a[i].first[0]>>s;
cin>>a[i].first[1]>>s;
cin>>a[i].first[2]>>s;
}
sort(a.begin(),a.end(),[](const pair<vector<int>,string> &x,const pair<vector<int>,string> &y){
if(x.first[0]<y.first[0])
return 1;
else if(x.first[0]==y.first[0]){
if(x.first[1]<y.first[1])
return 1;
else if(x.first[1]==y.first[1]){
if(x.first[2]<y.first[2])
return 1;
else if(x.first[2]==y.first[2]){
string s1,s2;
for(const char c:x.second)
s1.push_back(tolower(c));
for(const char c:y.second)
s2.push_back(tolower(c));
return s1<s2?1:0;
}
}
}
return 0;
});
for(int i=0;i<n;i++){
if(i%2==0)
cout<<"Row "<<(i/2+1)<<endl;
cout<<a[i].second<<endl;
}
if(!cin.eof())
cout<<endl;
}
}
#include <vector>
#include <string>
#include <cctype>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin>>n){
vector<pair<vector<int>,string> > a(n,make_pair(vector<int>(3),""));
for(int i=0;i<n;i++){
ws(cin);
string s;
cin>>a[i].second;
cin>>s;
cin>>a[i].first[0]>>s;
cin>>a[i].first[1]>>s;
cin>>a[i].first[2]>>s;
}
sort(a.begin(),a.end(),[](const pair<vector<int>,string> &x,const pair<vector<int>,string> &y){
if(x.first[0]<y.first[0])
return 1;
else if(x.first[0]==y.first[0]){
if(x.first[1]<y.first[1])
return 1;
else if(x.first[1]==y.first[1]){
if(x.first[2]<y.first[2])
return 1;
else if(x.first[2]==y.first[2]){
string s1,s2;
for(const char c:x.second)
s1.push_back(tolower(c));
for(const char c:y.second)
s2.push_back(tolower(c));
return s1<s2?1:0;
}
}
}
return 0;
});
for(int i=0;i<n;i++){
if(i%2==0)
cout<<"Row "<<(i/2+1)<<endl;
cout<<a[i].second<<endl;
}
if(!cin.eof())
cout<<endl;
}
}
Comments
Post a Comment