CF1184E2.Daleks' Invasion (medium)

提高+/省选-

通过率:0%

时间限制:15.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.

Your task is to calculate the number Emax(c)E_{max}(c), which is defined in the same way as in the easy version – i.e., the largest e≤109e \le 10^9 such that if we changed the energy of corridor cc to ee, the Daleks might use it – but now for every corridor that Heidi considers.

在一次成功的实地测试后,海蒂正考虑在某条走廊(不一定是第一条)部署陷阱。为了避免在时间漩涡中与戴立克相遇,出于充分谨慎的考虑,她只打算将陷阱部署在那些根据当前戴立克计划不会被使用的走廊上——而戴立克的计划是采用走廊的最小生成树(MST)。海蒂知道,现在各走廊所需的能量值互不相同,因此戴立克的计划是唯一确定的。

你的任务是:对海蒂所考虑的每一条走廊 cc,计算数值 Emax(c)E_{max}(c);该值的定义与简易版本中相同,即:最大的 e≤109e \le 10^9,使得若将走廊 cc 的能量值改为 ee,则戴立克有可能在他们的最小生成树中使用该走廊。

输入格式

The first line: number nn of destinations, number mm of Time Corridors (2≤n≤1052 \leq n \leq 10^5, n−1≤m≤106n - 1 \leq m \leq 10^6). The next mm lines: destinations aa, bb and energy ee (1≤a,b≤n1 \leq a, b \leq n, a≠ba \neq b, 0≤e≤1090 \leq e \leq 10^9).

No pair a,b{a, b} will repeat. The graph is guaranteed to be connected. All energy requirements ee are distinct.

第一行:目的地数量 nn,时间通道数量 mm(2≤n≤1052 \leq n \leq 10^5,n−1≤m≤106n - 1 \leq m \leq 10^6)。接下来的 mm 行:目的地 aa、bb 及所需能量 ee(1≤a,b≤n1 \leq a, b \leq n,a≠ba \neq b,0≤e≤1090 \leq e \leq 10^9)。

任意一对 {a,b}\{a, b\} 不会重复出现。图保证连通。所有能量需求 ee 互不相同。

输出格式

Output m−(n−1)m-(n-1) lines, each containing one integer: Emax(ci)E_{max}(c_i) for the ii-th Corridor cic_i from the input that is not part of the current Daleks' plan (minimum spanning tree).

输出 m−(n−1)m-(n-1) 行,每行包含一个整数:对于输入中第 ii 个**不属于当前戴立克计划(即最小生成树)**的走廊 cic_i,输出 Emax(ci)E_{max}(c_i)。

输入输出样例

  • 输入#1

    3 3
    1 2 8
    2 3 3
    3 1 4

    输出#1

    4

说明/提示

If m=n−1m = n-1, then you need not output anything.

如果 m=n−1m = n-1,则无需输出任何内容。

输入解题思路,AI测评打分。不知道怎么写?

首页