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

剪枝方法

Posted by L18 at 2007-11-14 19:57:59 on Problem 1753 and last updated at 2007-11-14 19:59:38
对当前翻动棋子的前一行进行检测

假如当前翻动棋子的坐标为(x,y),假设save[4][4]保棋子的信息

void DFS(...)
{

   for(...)  //进行DFS
  {
     if(x>=1&&y>=1) //检测前一行,进行剪枝
      {
         if(x-1>=0) save[x-1][y]=~save[x-1][y];
         for(j=0;j<y;j++) if(save[x-1][j]!=save[x-1][j+1]) break;
         if(x-1>=0) save[x-1][y]=~save[x-1][y];
         if(j!=y) continue;
     }
     ...       //修改数据

     DFS(...); 

     ...       //回滚数据
  }
}

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