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

建议使用的浏览器:

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

6218:Bridge

题目描述
Consider a 2 × n grid graph with nodes (x, y) where x ∈ {0, 1} and y ∈ {1, 2, · · · , n}. The initial graph has 3n - 2 edges connecting all pairs of adjacent nodes.
You need to maintain the graph with two types of different adjustments. The first one, denoted by “1 $x_0$ $y_0$ $x_1$ $y_1$”,adds an new edge between the nodes ($x_0, y_0$) and ($x_1, y_1$) which was not exist. The second one, denoted by“2 $x_0$ $y_0$ $x_1$ $y_1$”, erases an existed edge between the nodes ($x_0, y_0$) and ($x_1, y_1$).
It is sure that, for each adjustment, ($x_0, y_0$) and ($x_1, y_1$) were adjacent in the original grid graph. That is say thateither they share the same x coordinate and |$y_0 - y_1$| = 1, or they share the same y coordinate and |$x_0 - x_1$| = 1.
After each adjustment, we guarantee the connectedness of the graph and you need to calculate the number of bridges in the current graph.
输入解释
The first line of input contains an integer T (1 ≤ T ≤ 1001) which is the total number of test cases. For each test case, the first line contains integers n (1 ≤ n ≤ 200000) and m (0 ≤ m ≤ 200000); n indicates the size of the graph
and m is the number of adjustments. Each of the following m lines contains an adjustment described as above.
Only one case satisfies n + m ≥ 2000.
输出解释
For each test case, output m lines, each of which contains the number of bridges.
输入样例
2
4 8
2 0 3 1 3
2 0 2 1 2
2 0 4 1 4
1 0 2 1 2
1 0 3 1 3
2 0 1 1 1
1 0 4 1 4
2 1 2 1 3
6 2
2 1 2 1 3
2 0 4 0 5
输出样例
0
0
7
4
2
4
2
4
1
2
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

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

源链接: HDU-6218

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

共提交 0

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