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

我的转换函数(懒得写位运算,使用bitset)

Posted by zerocpp at 2011-03-31 00:46:20 on Problem 1753 and last updated at 2011-03-31 00:59:17
int flip(int b1, int i, int j)
{
	bitset<16> b(b1);
	b[i*4+j].flip();
	i>0 && b[(i-1)*4+j].flip();
	i<3 && b[(i+1)*4+j].flip();
	j>0 && b[i*4+(j-1)].flip();
	j<3 && b[i*4+(j+1)].flip();
	if (b.count() == 1 || b.count() == 15) return -1;//我想到的一个简单剪枝
	return b.to_ulong();
}

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