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!!, 我是用NP做的,提交总是报RE

Posted by jackrhc at 2009-03-02 13:36:45 on Problem 1014
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
struct node
{
	short num[6];
};
int main()
{
	short sum, count=0, i, j;
	short *find;
	node my;
	vector<node> left;
	while(true)
	{
		count++;
		for(sum=0,i=0;i<6;i++)
		{
			cin>>my.num[i];
			sum+=my.num[i]*(i+1);
		}
		if(sum==0)
			break;
		else if(sum%2==1)
			cout<<"Collection #"<<count
			<<":\nCan't be divided.\n\n";
		else
		{
			sum/=2;
			find=new short[sum+1];
			memset(find,-1,(sum+1)*sizeof(short));
			find[0]=0;
			left.push_back(my);
			for(i=1;i<=sum;i++)
			{
				for(j=1;j<=6;j++)
				{
					if(i>=j&&find[i-j]!=-1)
					{
						if(left.at(find[i-j]).num[j-1]>0)
						{
							my=left.at(find[i-j]);
							my.num[j-1]=my.num[j-1]-1;
							find[i]=left.size();
							left.push_back(my);
						}
					}
				}
			}
			if(find[sum]!=-1)
				cout<<"Collection #"<<count
					<<":\nCan be divided.\n\n";
			else
				cout<<"Collection #"<<count
					<<":\nCan't be divided.\n\n";
			delete[] find;
			left.clear();
		}
	}
	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