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:跪求测试数据,wA的太郁闷了。哪位大侠能帮我看看一下啊,谢谢了。

Posted by Fynable at 2008-08-26 23:21:14 on Problem 1020
In Reply To:跪求测试数据,wA的太郁闷了。哪位大侠能帮我看看一下啊,谢谢了。 Posted by:SLAMDUNK2008 at 2008-08-22 15:50:00
> #include<iostream>
> using namespace std;
> 
> void sort(int *p,int n)//排序
> {
> 	int i,j,temp;
> 	for(i=0;i<n-1;i++)
> 		for(j=0;j<n-i;j++)
> 	{
> 		if(p[j]<p[j+1])
> 		{
> 			temp=p[j];
> 			p[j]=p[j+1];
> 			p[j+1]=temp;
> 		}
> 	}
> }
> 
> int distribute(int **ps,int s,int x)//分配大的块
> {
> 	int i,j,k,l;
> 	for(i=0;i<s;i++)
> 	{
> 		 j=0;
> 		while(j<s&&ps[j][i]==1)
> 		{
> 			j++;
> 		}
> 		if(s-j>=x&&s-i>=x&&j<s)
> 		{
> 			for(k=j;k<x+j;k++)
> 				for(l=i;l<x+i;l++)
> 				{
> 					ps[k][l]=1;
> 				}
> 				return 1;
> 		}
> 	}
> 	return 0;
> }
> 
> int main()
> {
> 	int t,s,n;
> 	int i,j,k,sum,flag=1;
> 	int *p;
> 	int **ps;
> 	cin>>t;
> 	for(i=0;i<t;i++)
> 	{
> 		cin>>s>>n;
> 		flag=1;
> 		p=new int[n];
> 		sum=0;
> 		for(j=0;j<n;j++)
> 		{
> 			cin>>p[j];
> 			sum=sum+p[j]*p[j];
> 		}
> 		sort(p,n);
> 		if(sum!=s*s)
> 			cout<<"HUTUTU!"<<endl;
> 		else if(s==0)
> 		{
> 			cout<<"KHOOOOB!"<<endl;
> 		}
> 		else
> 		{
> 			ps=new int*[s];
> 			for(j=0;j<s;j++)
> 			{
> 				ps[j]=new int[s];
> 			}
> 			for(j=0;j<s;j++)
> 				for(k=0;k<s;k++)
> 					{
> 						ps[j][k]=0;
> 					}
> 			for(j=0;j<n;j++)
> 			{
> 				if(distribute(ps,s,p[j])==0)
> 				{
> 					cout<<"HUTUTU!"<<endl;
> 					flag=0;
> 					break;
> 				}
> 			}
> 			if(flag)
> 			{
> 				cout<<"KHOOOOB!"<<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