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

为什么是WRONG ANSWER??谢谢

Posted by xuning at 2007-04-08 16:24:30 on Problem 2092
#include <iostream.h>

void main()
{
	int x,n,i,j,p[10001],nowp[501],nofp=1,m[501],sm[501],t,max=0,smax=0,mnum=0,smnum=0,out[500],outsum=0;
	while (1)
	{
		cin>>n>>x;
		if (x==0&&n==0)
			return;

		for (i=1;i<=10000;i++)
			p[i]=0;
		for (i=1;i<=n;i++)
		{
			for (j=1;j<=x;j++)
			{
				cin>>t;
				if (p[t]==0)
				{
					p[t]=1;
					nowp[nofp++]=t;
				}
				else
				{
					p[t]++;
				}
			}
		}
		for (i=1;i<=nofp-1;i++)
		{
			if (p[nowp[i]]>max)
			{
				smax=max;
				max=p[nowp[i]];
				smnum=mnum;
				mnum=1;
				for (j=1;j<=smnum;j++)
				{
					sm[j]=m[j];
				}
				m[1]=nowp[i];
			}
			else 
				if (p[nowp[i]]==max)
				{
					mnum++;
					m[mnum]=nowp[i];
				}
				else 
					if (p[nowp[i]]>smax)
					{
						smnum=1;
						sm[1]=nowp[i];
						smax=p[nowp[i]];
					}
					else 
						if (p[nowp[i]]==smax)
						{
							smnum++;
							sm[smnum]=nowp[i];
						}
		}
		for (i=1;i<=10000;i++)
		{
			if (p[i]==smax)
				out[outsum++]=i;
		}
		for (i=0;i<=outsum-2;i++)
		{
			cout<<out[i]<<' ';
		}
		cout<<out[outsum-1]<<endl;
		max=0,smax=0,mnum=0,smnum=0,nofp=1,outsum=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