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

建议使用的浏览器:

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

6251:Inkopolis

题目描述

Inkopolis is the city in which Inklings live in, it can be regarded as an undirected connected graph with exactly $N$ vertices and $N$ edges between vertices. It is guaranteed that the graph doesn’t contain duplicated edges or self loops. Inklings can splatter a special type of colored ink to decorate the roads they live in. Inklings are capricious so they often change the color of the roads to celebrate the upcoming Splatfest.
The Splatfest lasts for exactly $M$ days, on each day Inklings will splatter ink on exactly one road, the color on this road will be coverd by the new color of the ink. At the end of each day, they wonder how many different colored regions are there in the Inkopolis. A colored region is a set of connected roads with same color, to be clear, two roads are in the same colored region if they have the same color and share a common vertex.
输入解释
The first line of the input gives the number of test cases, $T$. $T$ test cases follow.
For each test case, the first line contains two integers $N$ and $M$, where $N$ is the number of vertexes and roads in Inkopolis, and $M$ is the number of days that Splatfest lasts.
Following $N$ lines describe the roads between the vertexes. Each line contains 3 integers $x$, $y$, $c$, representing there is a road with color $c$ between the $x^{th}$ and the $y^{th}$ vertex.
Next following $M$ lines describe the operations on each day. Each line contains 3 integers $x$, $y$, $c$, representing an operation that Inklings splatter the ink with color $c$ to the road between the $x^{th}$ and the $y^{th}$ vertex, it is guaranteed that there is such a road.
$1 \leq T \leq 100$
$3 \leq N \leq 2 \times 10^5$
$1 \leq M \leq 2 \times 10^5$
$1 \leq x, y, c \leq n$
$\sum N, \sum M \leq 10^6$
输出解释
For each test case, output one line containing “Case #x:” first, where $x$ is the test case number (starting from 1).
The following $M$ lines each consists of an integer which is the number of colored regional in Inkopolis after each day.
输入样例
2
4 3
4 2 4
2 3 3
3 4 2
1 4 1
3 4 2
2 3 4
3 4 3
4 4
1 2 1
2 3 1
3 4 1
4 1 1
1 2 2
3 4 2
2 3 2
4 1 4
输出样例
Case #1:
4
3
3
Case #2:
2
4
2
2
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6251

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

共提交 0

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