# 1808 scoring Problems

Source: Internet
Author: User

Description

In the ACM/ICPC regional competition, the lead team can directly submit the answer to the question. However, if the answer is incorrect, the final score will be affected when the answer is submitted again. The Test System of the Competition judges the program submitted each time. The result is an AC or an error. The defender can see this result.

In order to reward outstanding teams and determine the qualification list for entering the world championship, when the two teams make the same number of questions, they will further rank based on the time they use. There are two parts of time: the first is the total solution time, and the second is the penalty time. The so-called penalty time refers to the time when the submission program is fined when it is not passed. Every failed submission will be increased by 20 minutes in the final ranking time. Do not time unsolved questions.

Your program will read a list of running results and print the top three scores.

Input

The input file contains several test datasets.

Each test data is composed of two parts. The first part contains a positive integer, which indicates the number of participating teams. The following rows are the results of each submission. Each row indicates the result of one submission, including the submission time, team number, question number, and ruling result.

When the submission time for a row is 0, the current dataset ends. When the number of participating teams is 0, all input ends.

The number of teams in each test set cannot exceed 100, and the number of submissions cannot exceed 10000.

Output

For each group of input, the top three scores are output, including the team number, number of questions, time spent in the competition, and ranking. Before the output ranking, You need to output "Case N", where n indicates the group of inputs currently.

Assume that several teams may be in the same rank. For example, if several teams are the third, all of them will be output; if two teams are the second, no third. When the team ranks the same, the team numbers are output from small to large.

Simulation questions

`#include<iostream>#include<string>using namespace std;struct team1{    int teamNumber;    int totalTime;    int ac_question;    int a[11];}team[100];void simpleSort(int n){    for(int i=2;i<=n;i++)    {        team1 temp=team[i];        int j=i-1;        while(j>0&&team[j].ac_question<temp.ac_question)        {            team[j+1]=team[j];            j--;        }        team[j+1]=temp;    }}int main(){    int teamSum;    int subTime,teamNumber,questionNumber;    string isAccepted;    int n=0;    cin>>teamSum;    while(teamSum)    {        n++;        for(int i=1;i<=teamSum;i++)        {            team[i].teamNumber=i;            team[i].totalTime=0;            team[i].ac_question=0;            for(int j=0;j<=10;j++)            team[i].a[j]=0;        }        cin>>subTime;        while(subTime)        {            cin>>teamNumber>>questionNumber>>isAccepted;            if(isAccepted=="yes") {                team[teamNumber].totalTime+=(subTime+team[teamNumber].a[questionNumber]*20);                team[teamNumber].ac_question++;                }            else team[teamNumber].a[questionNumber]++;            cin>>subTime;        }        simpleSort(teamSum);        if(team[1].ac_question==team[2].ac_question&&team[1].ac_question!=team[3].ac_question)        {            if(team[1].totalTime<team[2].totalTime) {                team1 temp=team[1];                team[1]=team[2];                team[2]=temp;            }        }        else if(team[1].ac_question==team[2].ac_question&&team[1].ac_question==team[3].ac_question)        {            for(int i=1;i<=2;i++)            for(int j=1;j<=3-i;j++)            {                if(team[j].ac_question<team[j+1].ac_question)                {                    team1 temp=team[j];                    team[j]=team[j+1];                    team[j+1]=temp;                }            }        }        cout<<"case "<<n<<":"<<endl;        for(int i=1;i<=3;i++)        cout<<team[i].teamNumber<<' '<<team[i].ac_question<<' '<<team[i].totalTime<<' '<<i<<endl;        cin>>teamSum;    }    return 0;}/*312 1 2 yes14 3 2 no25 3 1 yes29 1 1 no38 3 2 yes39 2 1 no45 1 1 no00*/`

Related Keywords:

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.