아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Cubic Cycle

시간 제한2초메모리 제한1024 MB

요약
정점이 50개 이하인 3-정규 그래프에서 해밀턴 사이클의 개수를 센다.
난이도

보통10점 중 7점

유형
그래프, 백트래킹, 비트 연산
정답자
아직 제출이 없습니다

문제

Consider an undirected graph GG with vertices VV and edges EE. A Hamiltonian Cycle is a subset of edges C⊆EC⊆E such that every vertex in vv is the endpoint of precisely two edges in CC and the graph HH with vertices VV and edges CC is connected. In simpler terms, the edges of CC form a single cycle that includes all vertices.

Hamiltonian cycles are beautiful objects, but can be hard to find. Your most recent homework assignment in your Graph Theory course has given you the task of finding a Hamiltonian cycle in a particular graph GG (or determine if one exists). The graph itself is also beautiful, each vertex in GG is the endpoint of precisely three edges.

But it feels unfair to produce only one Hamiltonian cycle. All Hamiltonian cycles deserve recognition! So, you decided that you will in fact produce all Hamiltonian cycles in your homework solution.

Your task is to count the number of Hamiltonian cycles you will have to produce in your homework solution.

Figure 1: Illustration of the three Hamiltonian cycles in the first sample input. The cycles are depicted with thick edges.

입력

The first line contains a single even integer NN (4≤N≤504≤N≤50) giving the number of nodes.

Then 3⋅N/23⋅N/2 lines follow, each containing two integers u,vu,v (0≤u\<N0≤u\<N, 0≤v\<N0≤v\<N, u≠vu≠v) describing an edge connecting vertex uu to vertex vv. You are guaranteed any pair of nodes is connected by at most one edge and that each node is the endpoint of precisely three edges in the input.

출력

Display a single line with a single integer indicating the number of Hamiltonian cycles in the given graph.

예제2

  1. 예제 1

    입력
    4
    0 1
    1 2
    2 3
    3 0
    0 2
    1 3
    
    예상 출력
    3
    
  2. 예제 2

    입력
    6
    0 1
    1 2
    2 3
    3 4
    4 5
    5 0
    0 3
    1 4
    2 5
    
    예상 출력
    6