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

my wa code is it problem of mathod?

Posted by Washington at 2005-09-07 21:38:24 on Problem 2596
#include <stdio.h>
#include <string.h>

int f[1<<11][11][7];
int se[11][7];
int main ()
{
	int t,c,i,j,k,r,m,n,max,di,cnt;
	scanf ("%d",&t);
	for (c=1;c<=t;c++)
	{
		memset (f,0,sizeof (f));
		memset (se,0,sizeof (se));
		scanf ("%d",&n);
		cnt=0;
		for (i=0;i<n;i++)
		{
			for (j=0;j<6;j++)
			{
				scanf ("%d",&se[i][j]);
				f[1<<i][i][j]=se[i][j];
			}
		}                        //输入色子信息和初始化f

		for (i=0;i<(1<<n);i++)
		{
			for (j=0;j<n;j++)
			{

				if ((i>>j)%2==0)
				{
					for (k=0;k<n;k++)
					{
						if ((i>>k)%2==0) continue;
						for (r=0;r<6;r++)
						{
							for (m=0,di=0;m<6;m++)
							{
								if (se[j][m]-1==r) {di=m;break;}
							}
							for (m=0,max=0;m<6;m++)
							{
								if (m!=di || m!=5-di)
								{
									if (se[j][m]>max) max=se[j][m];
								}
							}
							f[i+(1<<j)][j][se[j][5-di]-1]=f[i+(1<<j)][j][se[j][5-di]-1]>(f[i][k][se[j][di]-1]+max)?f[i+(1<<j)][j][se[j][5-di]-1]:(f[i][k][se[j][di]-1]+max);
							if (cnt<f[i+(1<<j)][j][se[j][5-di]-1])
								cnt=f[i+(1<<j)][j][se[j][5-di]-1];
	
						}
					}
				}
			}
		}//dp 过程
		
		printf ("%d\n",cnt);
	}
	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