Create 100820C_snowy_smile.cpp

From http://blog.csdn.net/snowy_smile/article/details/50156279
This commit is contained in:
Kirigaya Kazuto 2016-08-13 14:57:09 +08:00 committed by GitHub
parent 592fa8d5fe
commit 0f4fe98d55

View File

@ -0,0 +1,104 @@
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=1061109567;
int casenum,casei;
int n;
struct A
{
char name[300];
int b[50];
bool operator < (const A& bb)const
{
for(int i=0;i<48;++i)
{
if(b[i]>bb.b[i])return 1;
if(b[i]<bb.b[i])return 0;
}
return strcmp(name,bb.name)<0;
}
}a[1010];
char s[300];
int b[50];
int main()
{
while(~scanf("%d",&n))
{
MS(a,0);
for(int i=1;i<=n;++i)
{
scanf("%s",a[i].name);
int l=strlen(a[i].name);
a[i].name[l-1]=0;
int top=0;
while(1)
{
scanf("%s",s);
if(s[0]=='c')break;
if(s[0]=='u')b[++top]=1;
else if(s[0]=='m')b[++top]=0;
else if(s[0]=='l')b[++top]=-1;
}
int p=0;
while(top)a[i].b[p++]=b[top--];
}
sort(a+1,a+n+1);
for(int i=1;i<=n;++i)printf("%s\n",a[i].name);
}
}
/*
n1<=n<=1000n种难度的课程
n个人的课程难度按照从大到小排序
upper>middle>lower的顺序排序
middle
256/6
upper=1
middle=00
lower=-1
&&
O*nlogn
5
mom: upper upper lower middle class
dad: middle middle lower middle class
queenelizabeth: upper upper class
chair: lower lower class
unclebob: middle lower middle class
*/