Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

同问。。。

Posted by anonym11 at 2005-10-13 12:59:43 on Problem 2643
In Reply To:WA了。。。。怎么回事 Posted by:adamgic at 2005-10-13 12:51:11
> #include<iostream>
> #include<string>
> #include<map>
> using namespace std;
> int main()
> {
>     string candidate[20][2],tmpstr;
>     int VOTES[20];
>     map<string , int>mapstr;
>     int n,m;
>     cin>>n;getchar();
>     for(int i=0;i<n;i++){
>         getline(cin,candidate[i][0]);
>         getline(cin,candidate[i][1]);
>     }
>     cin>>m;getchar();
>     for(int i=0;i<m;i++){
>         getline(cin,tmpstr);
>         if(!mapstr.count(tmpstr)){
>             mapstr[tmpstr]=1;
>         }
>         else mapstr[tmpstr]++;
>     }
>     int maxvote=0,maxcount=0,maxpos=0;
>     for(int i=0;i<n;i++){
>         VOTES[i]=mapstr[candidate[i][0]];
>         if(maxvote<VOTES[i]){
>             maxvote=VOTES[i];
>             maxpos=i;
>         }
>     }
>     for(int i=0;i<n;i++){
>         if(VOTES[i]==maxvote){
>             ++maxcount;
>         }
>     }
>     if(maxcount>1)puts("tie");
>     else {
>         cout<<candidate[maxpos][1]<<endl;
>     }
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator