atcoder#ABC282D. [ABC282D] Make Bipartite 2
[ABC282D] Make Bipartite 2
Score : points
Problem Statement
You are given a simple undirected graph with vertices and edges (a simple graph does not contain self-loops or multi-edges). For , the -th edge connects vertex and vertex .
Print the number of pairs of integers that satisfy and both of the following conditions.
- The graph does not have an edge connecting vertex and vertex .
- Adding an edge connecting vertex and vertex in the graph results in a bipartite graph.
What is a bipartite graph?
An undirected graph is said to be bipartite if and only if one can paint each vertex black or white to satisfy the following condition.
- No edge connects vertices painted in the same color.
Constraints
- $0 \leq M \leq \min \lbrace 2 \times 10^5, N(N-1)/2 \rbrace$
- The graph is simple.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
5 4
4 2
3 1
5 2
3 2
2
We have two pairs of integers that satisfy the conditions in the problem statement: and . Thus, you should print . The other pairs do not satisfy the conditions. For instance, for , the graph has an edge connecting vertex and vertex ; for , adding an edge connecting vertex and vertex in the graph does not result in a bipartite graph.
4 3
3 1
3 2
1 2
0
Note that the given graph may not be bipartite or connected.
9 11
4 9
9 1
8 2
8 3
9 2
8 4
6 7
4 6
7 5
4 5
7 8
9