CF1599I.Desert
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an undirected graph of N nodes and M edges, E1,E2,…EM .
A connected graph is a cactus if each of it's edges belogs to at most one simple cycle. A graph is a desert if each of it's connected components is a cactus.
Find the number of pairs (L,R) , ( 1≤L≤R≤M ) such that, if we delete all the edges except for EL,EL+1,…ER , the graph is a desert.
输入格式
The first line contains two integers N and M ( 2≤N≤2.5×105 , 1≤M≤5×105 ). Each of the next M lines contains two integers. The i -th line describes the i -th edge. It contains integers Ui and Vi , the nodes connected by the i -th edge ( Ei=(Ui,Vi) ). It is guaranteed that 1≤Ui,Vi≤N and Ui=Vi .
输出格式
The output contains one integer number – the answer.
输入输出样例
输入#1
5 6 1 2 2 3 3 4 4 5 5 1 2 4
输出#1
20
输入#2
2 3 1 2 1 2 1 2
输出#2
5
说明/提示
In the second example: Graphs for pairs (1,1) , (2,2) and (3,3) are deserts because they don't have any cycles. Graphs for pairs (1,2) and (2,3) have one cycle of length 2 so they are deserts.