| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 1024 MB | 4 | 3 | 3 | 75.000% |
A simple undirected graph is an undirected graph that doesn't contain loops or multiple edges.
A planar graph is a simple undirected graph such that it can be embedded in the plane, i.e., it can be drawn on the plane in such a way that its edges intersect only at their common endpoints. In other words, it can be drawn in such a way that no edges cross each other.
An independent set is a set of vertices in a graph, no two of which are adjacent.
A tripartite graph is a simple undirected graph whose vertices can be divided into three disjoint independent sets.
You are given a planar graph. You are about to add a single edge to it. You know there is no way to add an edge, such that the resulting graph is planar. How many ways are there to add an edge such that the resulting graph is tripartite?
Note that you can not add multiple edges or loops because the resulting graph must be simple. Edges $a-b$ and $b-a$ are the same and should be counted once.
The first line of input contains two integers $n$ and $m$ (3ドル \leq n, m \leq 3 \cdot 10^5$) --- the number of vertices and the number of edges respectively.
$m$ lines follow. Each of them contains two integers $a$ and $b$ (1ドル \leq a, b \leq n, a \neq b$), meaning that there is an edge between vertices $a$ and $b$.
It's guaranteed that the graph conforms to the conditions described above.
Output a single integer --- the number of ways to add an edge, such that the resulting graph is tripartite.
3 3 1 2 1 3 2 3
0
4 6 1 2 3 1 4 1 2 3 3 4 2 4
0
8 18 1 2 1 3 1 4 1 5 1 6 1 7 2 3 3 4 4 5 5 6 6 7 2 7 8 2 8 3 8 4 8 5 8 6 8 7
3
Isn't the last sample sample beautiful and concise?