1140 Look-and-say Sequence

#include

#include

#include

#include

using namespace std;

class Record{

public:

string school;

double scores;

int num;

// int rank;

bool operator < (Record const a){

if(scores==a.scores)

{

if(num==a.num)return school

else return num

}

else return scores>a.scores;

}

};

 

string func(string str)

{

for(int i=0;i

{

if(str[i]>='A'&&str[i]<='Z') str[i]=str[i]-'A'+'a';

}

return str;

}

 

int main()

{

map schoolhash;

vector records;

int n;

int k=0;

cin>>n;

for(int i=0;i

{

string ID,school;

int score;

cin>>ID>>score>>school;

school = func(school);

map::iterator it = schoolhash.find(school);

if(it==schoolhash.end())

{

schoolhash[school] = k++;

Record tmp;

tmp.school = school;

double w = 1;

if(ID[0]=='B') w = 1/1.5;

if(ID[0]=='T') w = 1.5;

tmp.scores = score*w;

tmp.num = 1;

records.push_back(tmp);

}

else

{

int t = schoolhash[school];

records[t].num++;

double w = 1;

if(ID[0]=='B') w = 1/1.5;

if(ID[0]=='T') w = 1.5;

records[t].scores+=score*w;

}

}

for(int i=0;i

{

records[i].scores = int(records[i].scores);

}

sort(records.begin(),records.end());

int rank=1;

cout<

while(rank<=records.size())

{

int i = rank;

cout<

while(i

cout<

++i;

}

rank=i+1;

}

return 0;

}

你可能感兴趣的:(PAT【甲】)