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

第一次写位运算类型的BFS....顺便发下位运算的状态转移函数

Posted by majia5 at 2008-07-24 11:42:35 on Problem 1753 and last updated at 2008-07-24 11:46:39
居然忘记把自己这点取反拉.....
还有
居然是多case
题目好坏mislead我....
不过AC了就是好拉拉拉...happy....:)

新人写的不好见笑...

struct sta
{
	int state;/*用位保存保存状态的...保存在低16位*/
	int step;/*当前所走步数,其实可以不用...*/

}p,temp,s;
/*id从0..15*/
void move(sta *a,int id)
{
	a->state<<=id;
	a->state^=32768;/*把低第16位取反*/
	a->state>>=id;
/*如果存在下一行*/
	if(id<=11)
		{
			a->state<<=(id+4);
			a->state^=32768;
			a->state>>=(id+4);
		}
/*如果存在上一行*/
	if(id>=4)
	{
		a->state<<=(id-4);
		a->state^=32768;
		a->state>>=(id-4);
	}
/*如果是边界点(左边界)*/
	if(id==0||id==4||id==8||id==12)
		{
			a->state<<=(1+id);
			a->state^=32768;
			a->state>>=(id+1);
		}
	else
/*如果是边界点(右边界)*/
	if(id==3||id==7||id==11||id==15)
		{
			a->state<<=(id-1);
			a->state^=32768;
			a->state>>=(id-1);
		}
/*如果是其他中间点*/
	else
		{
			a->state<<=(id+1);
			a->state^=32768;
			a->state>>=2;
			a->state^=32768;
			a->state>>=(id-1);
		}
}

:)

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