Number of simple paths v2

Revision en1, by Farsh_LE, 2023-03-18 13:33:43

Hi codeforces

I was solving this problem:
You are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph.

Your task is to calculate the number of simple paths of length at least 1 in the given graph. Note that paths that differ only by their direction are considered the same (i. e. you have to calculate the number of undirected paths). For example, paths [1,2,3] and [3,2,1] are considered the same.

But I didn't notice that it has n edges (thought it had m edges which is given in the input), but I didn't find an answer better than n^2

so I want to ask , does anybody know a faster solution for the new problem(m edges )

Thanks!

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Farsh_LE 2023-03-18 13:33:43 1145 Initial revision (published)