现在的位置: 首页 > 综合 > 正文

真的不容易啊,挺进50道题目的行列了!

2013年10月06日 ⁄ 综合 ⁄ 共 7032字 ⁄ 字号 评论关闭

真的很不容易,我的第五十题选了一道昨天的竞赛题目。作为我第五十题,我很认真的对待,虽然试过好几次WA,但是最后终于AC了。做了好几个小时。虽然这道题我编出来的时间不长,但是修改花了不少时间,因为测试用例太过于变态了。我考虑的很完善,我的NAME是按字典排序,但是原来按输入顺序排就可以了。不过这五十题对我意义很重大,标志了我不再是新手了,我要向更高的目标进发!写代码真的是对人的意志的一种考验,我发现我真的很喜欢写代码了,尤其是喜欢AC的感觉!我会继续努力!!

 

Kick-Tipp
Time Limit:2000MS  Memory Limit:65536K
Total Submit:201 Accepted:72

Description

 

Input

 

Output

 

Sample Input

 

Sample Output

 

Source
TUD Programming Contest 2006, Darmstadt, Germany

 我的程序代码:

 

#include "iostream"
#include 
"vector"
#include 
"string"
#include 
"algorithm"
using namespace std;
typedef 
struct  
{
    
int Score;
    
int Dot;
    
char Name[50];
    
int i;
}
Information;
bool cmp(Information c1,Information c2)
{
    
if(c1.Score<c2.Score)
        
return false;
    
else if(c1.Score==c2.Score)
    
{
        
if(c1.Dot<c2.Dot)
            
return false;
        
else if(c1.Dot==c2.Dot)
        
{
            
if(c1.i<c2.i)
                
return true;
            
else
                
return false;
        }

        
else
            
return true;
    }

    
else
        
return true;
}

int main()
{
    
int s,Scenario,numberofpaticipate,numberofround;
    
int FirstTeamPoint,SecondTeamPoint;
    
int GuessFirstTeamPoint,GuessSecondTeamPoint,maxs;
    
int NumberOfSmallRound,ScoreOfPaticipate[50],DotOfPaticipate[50],ScoreOfEachRound[50];
    
int i;
    
char nameofpaticipate[50][100];
    
char ch;
    Information Temp;
    cin
>>s;
    Scenario
=1;
    
while(s)
    
{
        vector
<Information> OutputInformation;
        memset(ScoreOfPaticipate,
0,sizeof(ScoreOfPaticipate));
        memset(DotOfPaticipate,
0,sizeof(DotOfPaticipate));
        cin
>>numberofpaticipate>>numberofround;
        ch
=getchar();
        
for(i=0;i<numberofpaticipate;i++)
        
{
            gets(nameofpaticipate[i]);
        }

        cout
<<"Scenario #"<<Scenario<<":"<<endl;
        Scenario
++;
        
while(numberofround)
        
{
            cin
>>NumberOfSmallRound;
            memset(ScoreOfEachRound,
0,sizeof(ScoreOfEachRound));
            
while(NumberOfSmallRound)
            
{
                cin
>>FirstTeamPoint>>ch>>SecondTeamPoint;
                
for(i=0;i<numberofpaticipate;i++)
                
{
                    cin
>> GuessFirstTeamPoint >> ch >> GuessSecondTeamPoint;
                    
if(( GuessFirstTeamPoint == FirstTeamPoint ) && ( SecondTeamPoint == GuessSecondTeamPoint ) )
                    
{
                        ScoreOfPaticipate[i]
+=3;
                        ScoreOfEachRound[i]
+=3;
                    }

                    
else if(( FirstTeamPoint > SecondTeamPoint )&&( GuessFirstTeamPoint > GuessSecondTeamPoint ))
                    
{
                        ScoreOfPaticipate[i]
+=1;
                        ScoreOfEachRound[i]
+=1;
                    }

                    
else if(( FirstTeamPoint < SecondTeamPoint )&&( GuessFirstTeamPoint < GuessSecondTeamPoint ))
                    
{
                        ScoreOfPaticipate[i]
+=1;
                        ScoreOfEachRound[i]
+=1;
                    }

                    
else if(( FirstTeamPoint == SecondTeamPoint )&&( GuessSecondTeamPoint == GuessFirstTeamPoint )&&( FirstTeamPoint != GuessFirstTeamPoint ))
                    
{
                        ScoreOfPaticipate[i]
+=1;
                        ScoreOfEachRound[i]
+=1;
                    }

                    
else
                    
{
                        ScoreOfPaticipate[i]
+=0;
                        ScoreOfEachRound[i]
+=0;
                    }

                }

                NumberOfSmallRound
--;
            }

            maxs
=0;
            
for(i=0;i<numberofpaticipate;i++)
            
{
                
if(maxs<ScoreOfEachRound[i])
                
{
                    maxs
=ScoreOfEachRound[i];
                }

            }

            
for(i=0;i<numberofpaticipate;i++)
            
{
                
if(maxs==ScoreOfEachRound[i])
                
{
                    DotOfPaticipate[i]
+=1;
                }

            }

            numberofround
--;
        }

        
for(i=0;i<numberofpaticipate;i++)
        
{
            strcpy(Temp.Name,nameofpaticipate[i]);
            Temp.Score
=ScoreOfPaticipate[i];
            Temp.Dot
=DotOfPaticipate[i];
            Temp.i
=i;
            OutputInformation.push_back(Temp);
        }

        sort(OutputInformation.begin(),OutputInformation.end(),cmp);
        
for(i=0;i<numberofpaticipate;i++)
        
{
            cout
<<OutputInformation[i].Score<<" "<<OutputInformation[i].Dot<<" "<<OutputInformation[i].Name<<endl;
        }

        cout
<<endl;
        s
--;
    }

    
return 0;
}
Scenario #1:
7 2 Guenter Netzer
3 0 Gerhard Delling

Scenario #2:
3 1 Johannes B. Kerner
3 1 Urs Meier
3 1 Juergen Klopp
2
2 2
Gerhard Delling
Guenter Netzer
1
4 : 3
0 : 1
1 : 0
2
1 : 0
1 : 0
1 : 0
0 : 0
2 : 1
0 : 0
3 1
Johannes B. Kerner
Urs Meier
Juergen Klopp
1
2 : 1
2 : 1
2 : 1
2 : 1

The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario starting at 1. Then print a sorted table of p lines giving the number of points, the number of dots, and the names of the participants in the following order:

  1. Participants with more points rank higher.
  2. Among those with an equal number of points, participants with more dots rank higher.
  3. If there is still a tie, use the order of the input.

In each line, the number of points, the dots, and the name must be separated by single spaces. Terminate the output for the scenario with a blank line.

The first line contains the number of scenarios. Each scenario starts with a line containing the number of participants p (1 ≤ p ≤ 50) and the number of rounds r (1 ≤ r ≤ 14). First come p lines, where the i-th such line contains the name of the i-th participant. Each name is guaranteed to be shorter than 50 characters. Then follow r descriptions of individual rounds.

Each round again consists of individual games, and thus starts with a line containing the number g (1 ≤ g ≤ 16) of games in this round. Next, there are the g descriptions of these games.

A description of a game is given by a line containing the result followed by exactly p lines with the predicted results, where the i-th such line gives the result predicted by participant i. Each result is given in the format X : Y (with one space before and after the colon) where X and Y are non-negative integers.

With the FIFA World Cup 2006™®†, a lot of people run world cup pools, where friends or colleagues can join and predict the outcome of the world cup games. The world cup is divided into several rounds, each of which consists of several games. After each game, you gain points for correctly predicting the winner as well as for predicting the exact outcome. After each round, the one who scored highest that round receives a separate point — from now on called a dot — which might later serve as a tie-breaker. If several people have scored highest, a dot is given to all of them.

After the world cup, the one who scored highest wins the pot, or, if you decided not to play for money, unstinted admiration for being such an outstanding soccer expert.

A few weeks ago you thought that sounded fun, so you are also running a pool for your friends. But now, the world cup is about to end. The finals are tomorrow, and still you do not know who scored how. You decide to write a program that will help you find out.

Given a list of the participants, those peoples’ bets, and the outcomes of the games, calculate each participant’s total number of points as well as the number of dots he received and output the sorted list of scores.

With your pool, you gain one point for correctly guessing which team wins, respectively whether the game ends in a draw. You receive two additional points for exactly guessing the correct result.

抱歉!评论已关闭.