Grid division-Group B of the 8th Lanqiao Cup Provincial Competition

The grid is divided into a 6x6 grid and cut into two parts along the edge of the grid. The shapes of the two parts are required to be exactly the same as shown in the figure: p1.png, p2.png, p3.png
are feasible segmentation methods.

Try to calculate: Including these three division methods, how many different division methods are there in total? Note: Rotational symmetry belongs to the same division method.
Please submit the whole number, do not fill in any extra content or explanatory text.
Blue Bridge Cup

Insert picture description here
Insert picture description here
Insert picture description here
This question is indeed very clever. I am still thinking about how to search for squares to walk all the routes, and also to check whether it is symmetrical and repetitive after rotation. But it is very troublesome to think about it this way, and many of them cannot be drawn in one stroke . Think about it carefully and find that it is very cumbersome and I still don't know whether the correct answer can be found in the end.
After seeing the idea of ​​a big man, I realized that there is no need for such troubles, just take the gaps between the squares as edges and walk along the point dfs. Go to the outside, and finally deal with 4 at the beginning. Of course, it is very important that the movement in one direction is also marked on the other side with the midpoint (4, 4) as the center of symmetry.
code show as below:

#include <iostream>
#include <string.h>
using namespace std;
int sum=0,book[10][10],nest[4][2]={
    
    {
    
    1,0},{
    
    0,1},{
    
    -1,0},{
    
    0,-1}};
void dfs(int x,int y)
{
    
    
 int i,tx,ty;
 if(x==1||x==7||y==1||y==7)
 {
    
    
  sum++;
  return;
 }
 for(i=0;i<=3;i++)
 {
    
    
  tx=x+nest[i][0];
  ty=y+nest[i][1];
  if(tx>7||ty>7||tx<1||ty<1)
  continue;
  if(book[tx][ty]==0)
  {
    
    
   book[tx][ty]=1;
   book[8-tx][8-ty]=1;
   dfs(tx,ty);
   book[tx][ty]=0;
   book[8-tx][8-ty]=0;
  }
 }
 return;
}
int main()
{
    
    
 memset(book,0,sizeof(book));
 book[4][4]=1;
 dfs(4,4);
 cout<<(sum/4)<<endl;
 return 0;
}

Guess you like

Origin blog.csdn.net/HT24k/article/details/105664093