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

请大牛帮忙看一下为什么会WA?~~~~~~~~谢谢!

Posted by yf at 2006-07-12 09:31:18 on Problem 2643
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin>>n; getchar();
	string  candi[20];
	string  party[20];
	int i;
	for(i=0;i<n;i++)
	{
		getline(cin,candi[i]);
		getline(cin,party[i]);
	}
	int m;
	cin>>m;  getchar();
	int count[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	string  elect[10000];
	for(i=0;i<m;i++)
	{
		getline(cin,elect[i]);
		for(int j=0;j<n;j++)
		{
			if(elect[i]==candi[j]){ count[j]++;break;}
		}
	}
	int t=0;
	for(int j=1;j<n;j++)
	   if(count[t]<count[j]){t=j;}

	int max=count[t];
	count[t]=0;
	int p=0;
	for(j=1;j<n;j++)
			if(count[p]<count[j]) {p=j;}
	
	if(max==count[p]) cout<<"tie"<<endl;
	else
	{
		cout<<party[t]<<endl;
	}
    return 0;
}

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