AtCoder Grand Contest 011
翻译中…
Problem Statement
翻译中…
Takahashi has received an undirected graph with $N$ vertices, numbered $1$, $2$, ..., $N$. The edges in this graph are represented by $(u_i, v_i)$. There are no self-loops and multiple edges in this graph.
翻译中…
Based on this graph, Takahashi is now constructing a new graph with $N^2$ vertices, where each vertex is labeled with a pair of integers $(a, b)$ ($1 \leq a \leq N$, $1 \leq b \leq N$). The edges in this new graph are generated by the following rule:
翻译中…
- Span an edge between vertices
$(a, b)$and$(a', b')$if and only if both of the following two edges exist in the original graph: an edge between vertices$a$and$a'$, and an edge between vertices$b$and$b'$.
翻译中…
How many connected components are there in this new graph?
翻译中…
Constraints
翻译中…
$2 \leq N \leq 100,000$$0 \leq M \leq 200,000$$1 \leq u_i < v_i \leq N$- There exists no pair of distinct integers
$i$and$j$such that$u_i = u_j$and$v_i = v_j$.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N M
u_1 v_1
u_2 v_2
:
u_M v_M
翻译中…
Output
翻译中…
Print the number of the connected components in the graph constructed by Takahashi.
翻译中…
样例
Input #1
3 1
1 2
Output #1
7
The graph constructed by Takahashi is as follows.

Input #2
7 5
1 2
3 4
3 5
4 5
2 6
Output #2
18
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。