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:一直说我错,为什么? 谁能给组数据?

Posted by renshubing at 2019-07-28 19:59:07 on Problem 3037
In Reply To:一直说我错,为什么? 谁能给组数据? Posted by:bmexue at 2006-10-24 10:18:48
> #include <iostream>
> #include <cmath>
> using namespace std;
> 
> struct Point
> {
> 	int i;
> 	int j;
> };
> int H[101][101]; //¼Ç¼¸ß¶È
> unsigned int M[101][101];   //¼Ç¼µ±Ç°ÐèÒªµÄÏà¶Ôʱ¼ä
> unsigned int LEVT[101][101];
> bool FIR[101][101];  //ÊDz»ÊÇÒѾ­ÅжϳöÀ´ÁË
> int V, R, C;
> Point HaveGot_isBianJie[10000];
> int num_Got;
> unsigned int pow2(int n)   //n>=0
> { 
>   if(n ==0)
> 	  return (unsigned int)0;
>   unsigned int tmpN =(unsigned int)n;
>   unsigned int i=1;
>   unsigned int rst =2;
>   while(i<tmpN)
>   {
>      rst = rst<<1;
> 	 i++;
>   }
>   return rst;
> }
> bool is_bianjie(int x, int y)
> {
> 	int tmp =0;
> 	if(x>1)
> 	{
> 		if(!FIR[x-1][y])
>               return true;
> 	}
> 	if(x<R)
> 	{
>        if(!FIR[x+1][y])
>               return true;
> 	}
> 	if(y>1)
> 	{
> 		if(!FIR[x][y-1])
> 		return true;
> 	}
> 	if(y<C)
> 	{
> 		if(!FIR[x][y+1])
> 			return true;
> 	}
> 	return false;	
> }
> int findmin()
> {
> 	int p,x,y;
>     x = HaveGot_isBianJie[0].i;
> 	y = HaveGot_isBianJie[0].j;
>     double tmp  = LEVT[x][y];
>     p = 0;
> 	for(int i=1; i<num_Got;i++)
> 	{
>         x = HaveGot_isBianJie[i].i;
> 		y = HaveGot_isBianJie[i].j;
> 		if( !is_bianjie(x,y) )
> 			continue;
> 		if( LEVT[x][y] < tmp)
> 		{
> 			tmp = LEVT[x][y];
> 			p = i;
> 		}
> 	}
> 	return p;
> }
> void make4zhou(int p)
> {
> 	int i = HaveGot_isBianJie[p].i;
> 	int j = HaveGot_isBianJie[p].j;
>     bool isuseOld = false;
> 	unsigned int lev = LEVT[i][j] ;
> 	if(j>1 && !FIR[i][j-1])
> 	{
> //		GETT[i][j-1] = lev;
>         LEVT[i][j-1] = lev + M[i][j-1];
> 		FIR[i][j-1] = true;
> 		if(!isuseOld)
> 		{
>            HaveGot_isBianJie[p].i = i;
>            HaveGot_isBianJie[p].j = j-1;
> 		   isuseOld = true;
> 		}
> 	} 
>     if(j<C && !FIR[i][j+1])
> 	{
> //		GETT[i][j+1] = lev;
> 		LEVT[i][j+1] = lev + M[i][j+1];
> 		FIR[i][j+1] = true;
>  		if(!isuseOld)
> 		{
>            HaveGot_isBianJie[p].i = i;
>            HaveGot_isBianJie[p].j = j+1;
> 		   isuseOld = true;
> 		}
> 		else
> 		{
> 			HaveGot_isBianJie[num_Got].i = i;
>          	HaveGot_isBianJie[num_Got].j = j+1;
>             num_Got++;
> 		}
> 
> 	}
> 	if(i>1 && !FIR[i-1][j] )
> 	{
> //		GETT[i-1][j] = lev;
> 		LEVT[i-1][j] = lev + M[i-1][j];
> 		FIR[i-1][j] = true;
>  		if(!isuseOld)
> 		{
>            HaveGot_isBianJie[p].i = i-1;
>            HaveGot_isBianJie[p].j = j;
> 		   isuseOld = true;
> 		}
> 		else
> 		{
> 			HaveGot_isBianJie[num_Got].i = i-1;
>          	HaveGot_isBianJie[num_Got].j = j;
>             num_Got++;
> 		}
> 	}
> 	if(i<R && !FIR[i+1][j])
> 	{
> //		GETT[i+1][j] = lev;
> 		LEVT[i+1][j] = lev + M[i+1][j];
> 		FIR[i+1][j] = true;
>  		if(!isuseOld)
> 		{
>            HaveGot_isBianJie[p].i = i+1;
>            HaveGot_isBianJie[p].j = j;
> 		   isuseOld = true;
> 		}
> 		else
> 		{
> 			HaveGot_isBianJie[num_Got].i = i+1;
>          	HaveGot_isBianJie[num_Got].j = j;
>             num_Got++;
> 		}
> 	}
> }
> 
> void work()
> {
> 	int tmp = H[1][1];
> 	for(int i=1;i<=R;i++)
> 	{
> 	   for(int j =1; j<= C;j++)
> 	   {
> 		   M[i][j] = pow2( H[i][j] + 25);
> 		   FIR[i][j] = false;
> 	   }
> 	}
> 	HaveGot_isBianJie[0].i =1;
> 	HaveGot_isBianJie[0].j =1;
> 	num_Got = 1;
> 	LEVT[1][1] = M[1][1];
> 	FIR[1][1] = true;
>     while(true)
> 	{
> 		int p =findmin();
>         make4zhou(p);
> 		if(FIR[R][C] == true)
> 			break;
> 	}
>     double rst = (double)LEVT[R][C] - (double)M[R][C];
> 	double tv = (double)V * pow(2.0, (double) ((double)H[1][1] + 25.0) );
> 	rst = rst/(double)tv;
> 	printf("%.2f\n",rst);
> }
> int main()
> {
> 	scanf("%d%d%d", &V,&R,&C);
>     for(int i=1;i<=R;i++)
> 	{
> 		for(int j =1; j<= C;j++)
> 			scanf("%d",&H[i][j]);
> 	}
>     work();
> 	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