1141 Pat ranking of institutions [difficult]

Source: Internet
Author: User

1141 Pat ranking of institutions (25 points)

After each pat, the Pat center will announce the ranking of institutions based on their students 'ces. Now you are asked to generate the ranklist.

Input specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤ 10? 5 ??), Which is the number of testees. Then n lines follow, each gives the information of a testee in the following format:

ID Score School

WhereIDIs a string of 6 characters with the first one representing the test level:BStands for the basic level,AThe Advanced Level andTThe top level;ScoreIs an integer in [0,100]; andSchoolIs the institution code which is a string of no more than 6 English letters (Case Insensitive). Note: it is guaranteed thatIDIs unique for each testee.

Output specification:

For each case, first print in a line the total number of institutions. Then output the ranklist of institutions in nondecreasing order of their ranks in the following format:

Rank School TWS Ns

WhereRankIs the rank (start from 1) of the institution;SchoolIs the institution code (all in lower case );;TWSIs the total weighted score which is defined to be the integer partScoreB/1.5 + ScoreA + ScoreT*1.5, WhereScoreXIs the total score of the testees belong to this institution on LevelX; AndNsIs the total number of testees who belong to this institution.

The institutions are ranked according to theirTWS. If there is a tie, the institutions are supposed to have the same rank, and they shall be printed in ascending orderNs. If there is still a tie, they shall be printed in alphabetical order of their codes.

Sample input:
10A57908 85 AuB57908 54 LanXA37487 60 auT28374 67 CMUT32486 24 hypuA66734 92 cmuB76378 71 AUA47780 45 lanxA72809 100 pkuA03274 45 hypu
Sample output:
51 cmu 192 21 au 192 33 pku 100 14 hypu 81 24 lanx 81 2

The student ID, score, and school are given, and then the related ranking of the school is calculated. The score of the examinee in the test room is calculated, and finally ranked by a rule.

// This question is really troublesome.

# Include <iostream> # include <vector> # include <map> # include <algorithm> using namespace STD; struct Sch {int Sb, SA, St; int fin, Stu; string name; Sch (string N) {name = N; sb = 0; SA = 0; ST = 0; Stu = 1;} void CAL () {// but how do I obtain the integer part? If the value is assigned directly, it should be 4 to 5. Fin = Sb/1.5 + SA + st * 1.5 ;}; string lower (string s) {for (INT I = 0; I <S. size (); I ++) {If (s [I]> = 'A' & S [I] <= 'Z ') {s [I] = s [I]-'A' + 'A' ;}}return s ;}map <string, int> name2id; vector <Sch> vsch; void add (string ID, int index, int score) {If (ID [0] = 'A') vsch [Index]. sa + = score; else if (ID [0] = 'B') vsch [Index]. sb + = score; else vsch [Index]. st + = score;} bool CMP (Sch & A, Sch & B) {// sorting function. If (. fin> B. fin) return true; else if (. fin = B. fin &. stu <B. stu) return true; else if (. fin = B. fin &. stu = B. stu &. name <B. name) return true;} int main () {int N; CIN> N; string ID, SH; int SCO, Ct = 0; // CT indicates the number of schools. For (INT I = 0; I <n; I ++) {CIN> ID> SCO> Sh; SH = lower (SH ); // how do I convert the case sensitivity of a function? If (name2id. count (SH) = 0) {// if the current organization does not exist, name2id [sh] = CT ++; vsch. push_back (Sch (SH); // name the organization. Add (ID, CT-1, SCO);} else {// If int temp = name2id [sh]; add (ID, temp, SCO); vsch [temp] already exists. stu ++; // another student is added.} Int size = name2id. size (); cout <size <'\ n'; // calculate the score; For (INT I = 0; I <vsch. size (); I ++) {vsch [I]. cal ();} Sort (vsch. begin (), vsch. end (), CMP); int Rank = 1; for (INT I = 0; I <size; I ++) {if (I! = 0) {If (vsch [I]. Fin! = Vsch [I-1]. fin) rank ++; // This time the ranking is only +; // other situations do not rank + +} cout <rank <"" <vsch [I]. name <"" <vsch [I]. fin <"" <vsch [I]. stu <'\ n';} return 0 ;}
Wrong

 

// I wrote this for nearly an hour, but the final result of the first submission is as follows:

It's really cool in my heart. Let's see Liu Shen later.

1141 Pat ranking of institutions [difficult]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.