当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6200:mustedge mustedge mustedge

题目描述
Give an connected undirected graph with $n$ nodes and $m$ edges, ($n,m\leq 10^5$) which has no selfloops or multiple edges $initially$.
Now we have $q$ operations ($q\leq 10^5$):
  
$\cdot 1\ u\ v$: add an undirected edge from $u$ to $v$; $(u \neq v\&\& 1 \leq u,v \leq n)$
$\cdot 2\ u\ v$: count the number of $mustedges$ from $u$ to $v$; $(1 \leq u,v \leq n)$.

$mustedge$: we define set $E_i$ as a path from $u$ to $v$ which contain edges in this path, and $| \cap_1^kE_i |$ is the number of $mustedges$. $| x |$ means size of set $x$, and $E_1, E_2\dots E_k$ means all the paths.
It's guaranteed that $\sum{n},\sum{m},\sum{q}\leq 10^6$
Please note that maybe there are more than one edges between two nodes after we add edges. They are not the same, which means they can be in a set at the same time. Read the sample data for more information.
输入解释
Input starts with an integer $T$, denoting the number of test cases.
For each case:
First line are two number $n$ and $m$;
Then next $m$ lines, each contains two integers $u$ and $v$, which indicates an undirected edge from $u$ to $v$;
Next line contains a number $q$, the number of operations;
Then next $q$ lines, contains three integers $x$, $u$ and $v$ where $x$ is the operation type, which describes an operation.

输出解释
For each test case, output "Case #x:" where $x$ is the test case number starting from 1.
In each test case, print a single number one line when query the number of $mustedges$.
输入样例
2
4 3
1 2
2 3
3 4
5
2 1 4
1 2 3
2 1 4
2 2 3
2 2 4
8 9
1 2
2 3
1 3
3 4
4 5
4 6
5 7
5 8
7 8
5
2 7 8
2 1 6
2 4 7
1 6 8
2 5 6
输出样例
Case #1:
3
2
0
1
Case #2:
0
2
1
0
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6200

最后修改于 2020-10-25T23:29:15+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 32768/32768K(Java/Others)