#P8605. [蓝桥杯 2013 国 AC] 网络寻路
[蓝桥杯 2013 国 AC] 网络寻路
Problem Description
A network in Country uses several links to connect several nodes. Communication between nodes is bidirectional. For security reasons, an important data packet must be forwarded exactly twice to reach its destination. The packet may be generated at any node, and we need to know how many different forwarding paths there are in this network.
The source and destination can be the same, but the intermediate nodes must be different.
For the network shown in Figure :

is allowed.
or are both invalid.
Constraints
, .
Notes
Updated on 2024/1/28: added a set of hack testdata.
Input Format
The first line of the input contains two integers , representing the number of nodes and the number of links, respectively .
The next lines each contain two integers and , indicating that node and node are connected .
The input guarantees that there is at most one edge between any two nodes, and there are no edges from a node to itself, i.e., there are no multiple edges or self-loops.
Output Format
Output one integer, representing the number of paths that satisfy the requirements.
3 3
1 2
2 3
1 3
6
4 4
1 2
2 3
3 1
1 4
10
Hint
Time limit: 1 second. Memory limit: 64 MB. Lanqiao Cup 2013, the 4th National Final.
Translated by ChatGPT 5