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

Re:这里的测试数据都过了,武大acm也能通过,这里始终wa,快疯了,各位有没有其他的数据?

Posted by zsasuke at 2008-08-21 16:58:14 on Problem 1011
In Reply To:这里的测试数据都过了,武大acm也能通过,这里始终wa,快疯了,各位有没有其他的数据? Posted by:csucrab at 2008-08-12 10:59:26
> 武大acm本题网址
> http://acm.whu.edu.cn/oak/problem/problem.jsp?problem_id=1212
> 
> Run ID User Problem Result Memory Time Language Length Submit Time 
> 77688 csucrab 1212 Accepted  1128 5 G++  3140 2008-08-12 10:34:51.0 
> 
> 但是在这里仍然是wa,请问还有什么特别的数据吗,快疯了,谢谢。
我更晕,北大的通过了,武大的却过不掉
#include<iostream>
#include<algorithm>
using namespace std;
int n,length,r,data[101],used[101],max1,sum,Find,ok,aim,o,res;
int search(int begin,int end,int use,int add)
{    if(add==end-1||begin>=end-1||(end-begin-use)/2+Find<aim)
            return 0;

	int i=end-1;
	int p=0;
	if(used[end-1])
	{
	while(used[i]&&i>add)
	{	i--;
	p++;
	}
	if(i==add)
		return 0;
	return search(begin,i+1,use-p,add);
	}
	if(data[add]+data[end-1]>length)
		return 0;
	for(i=add;i<end-1;i++)
		if(used[i]==0&&data[i]+data[end-1]>=length)
			break;
		if(i==end-1||data[i]+data[end-1]>length)
		{   int j,t=0,f,former=0;
		    for(j=add;j<i;j++)
			{  
				if(used[j]==0)
				{  if(data[j]==former)
				          continue;
				data[end-1]+=data[j];
				used[j]=1;
				f=j;
					t=1;
				f++;
				while(used[f])
				{	f++;
			
				}
				if(f==end-1)
				{
					used[j]=0;
					data[end-1]-=data[j];
					return 0;
				}
                if(search(begin,end,use+1,f))
					return 1;
				former=data[j];
				data[end-1]-=data[j];
				used[j]=0;
	          	}
			}
		}
		else
		{   int j;
			used[i]=1;
			data[end-1]=length;
			Find++;
		    if(Find==aim-1||Find==aim)
				return 1;
			for(j=begin;j<end-1;j++)
			{
				if(used[j]==0)
					break;
			}
			if(j<end-1)
			{
			if(search(begin,end-1,use+1,j))
				return 1;
			}
			
             	used[i]=0;
				Find--;
				data[end-1]-=data[i];
				return 0; 
		}
		return 0;
}
			

					




int main()
{
	
     while(1)
	 {  ok=0;
		 cin>>n;
		 if(n==0)
			 break;
		 int i;
	
	    
		sum=max1=0;
				for(i=1;i<=n;i++)
		{	
		    cin>>data[i];
					        if(data[i]>max1)
					max1=data[i];
				sum+=data[i];
		}
		memset(used,0,404);
		sort(data+1,data+n+1);
		for(res=n;res>=2;res--)
		{
			if(sum%res||(length=sum/res)<max1)
				continue;
			Find=0;
			o=0;
			for(i=n;i>=1;i--)
			{
				if(data[i]==length)
				{	Find++;
				o=i;
				}
			}
			if(o==0)
				o=n+1;
			if(Find==res)
			{	cout<<sum/res<<endl;
		
			ok=1;
			break;
			}
              
			ok=0;
			aim=res;
		
			if(search(1,o,0,1))
			{	cout<<sum/res<<endl;
		
			ok=1;
			break;
			}
			memset(used,0,404);
		}
		if(ok)
			continue;
		cout<<sum<<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