The process of full arrangement can be regarded as a tree traversal process. Each leaf node is an arrangement. However, it should be noted that the edges of each subtree cannot overlap with the edges of the parent node. The tree traversal process is easy to handle, either recursively, using a stack or queue, or even setting up an array to save the state. The problem that the edges of the subtree cannot overlap with the edges of the parent node is also easy to handle. When traversing the subtree, only traverse available , and just mark it after traversing it. I think this problem is easier to solve if it is converted into a tree. It can be implemented in various ways.
The process of full arrangement can be regarded as a tree traversal process. Each leaf node is an arrangement. However, it should be noted that the edges of each subtree cannot overlap with the edges of the parent node.
The tree traversal process is easy to handle, either recursively, using a stack or queue, or even setting up an array to save the state. The problem that the edges of the subtree cannot overlap with the edges of the parent node is also easy to handle. When traversing the subtree, only traverse available , and just mark it after traversing it.
I think this problem is easier to solve if it is converted into a tree. It can be implemented in various ways.