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

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

Enigmatic Enumeration

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

요약
정점 3000개, 간선 6000개 이하의 무방향 그래프에서 서로 다른 최단 사이클의 개수를 센다.
난이도

보통10점 중 7점

유형
그래프, 최단 경로, BFS, 조합론
정답자
아직 제출이 없습니다

문제

Your friend Cajsa had a graph with nn vertices, and she needed to find its shortest cycle. To do this, she just took a random sequence of vertices and luckily this happened to be a shortest cycle. "What are the odds?", she asked herself and wrote another program to calculate this probability.

To do this, Cajsa needed an algorithm to count the number of shortest cycles in a graph. She uses a homemade randomized algorithm that runs in O(1)\mathcal{O}(1). But you suspect that this algorithm is incorrect, because surely it would have to consider every vertex of the graph (right?). You think that Cajsa's algorithm just prints random numbers that happen to be correct on some small graphs.

In response to these doubts, Cajsa generated a bunch of graphs, and challenges you to check that her answers are correct.

You are given an undirected graph with nn vertices and mm edges, and your task is to count the number of shortest cycles in it.

A cycle in a graph is a path of distinct vertices where, additionally, there is an edge between the first and last vertices of the path. Two cycles are considered distinct if they don't consist of the same set of edges. Thus the cycles 3,1,23, 1, 2 and 3,2,13, 2, 1 are the same, and the cycles 1,2,31, 2, 3 and 2,3,12, 3, 1 are considered the same.

입력

The first line of input contains two integers nn and mm (3≤n≤30003 \leq n \leq 3000, 3≤m≤60003 \leq m \leq 6000), the number of vertices and the number of edges.

The following mm lines each contain two integers u_iu\_i and v_iv\_i (1≤u_i≠v_i≤n1 \leq u\_i \neq v\_i \leq n), indicating that an undirected edge goes between u_iu\_i and v_iv\_i. The graph will not contain duplicate edges or self-loops.

It is guaranteed that the graph contains at least one cycle. However, note that the graph does not have to be connected.

출력

Print one integer, the number of shortest cycles in the graph.

예제3

  1. 예제 1

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

    입력
    5 10
    1 2
    1 3
    1 4
    1 5
    2 3
    2 4
    2 5
    3 4
    3 5
    4 5
    
    예상 출력
    10
    
  3. 예제 3

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