CF1045C.Hyperspace Highways
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In an unspecified solar system, there are N planets. A space government company has recently hired space contractors to build M bidirectional Hyperspace™ highways, each connecting two different planets. The primary objective, which was to make sure that every planet can be reached from any other planet taking only Hyperspace™ highways, has been completely fulfilled. Unfortunately, lots of space contractors had friends and cousins in the Space Board of Directors of the company, so the company decided to do much more than just connecting all planets.
In order to make spending enormous amounts of space money for Hyperspace™ highways look neccessary, they decided to enforce a strict rule on the Hyperspace™ highway network: whenever there is a way to travel through some planets and return to the starting point without travelling through any planet twice, every pair of planets on the itinerary should be directly connected by a Hyperspace™ highway. In other words, the set of planets in every simple cycle induces a complete subgraph.
You are designing a Hyperspace™ navigational app, and the key technical problem you are facing is finding the minimal number of Hyperspace™ highways one needs to use to travel from planet A to planet B. As this problem is too easy for Bubble Cup, here is a harder task: your program needs to do it for Q pairs of planets.
在某个未指明的太阳系中,共有 N 颗行星。一家太空政府公司最近聘请了太空承包商,修建了 M 条双向“超空间™”高速公路,每条公路连接两颗不同的行星。最初的主要目标——确保任意两颗行星之间均可仅通过“超空间™”高速公路相互抵达——已完全实现。然而,由于大量太空承包商在该公司“太空董事会”中拥有朋友和表亲等关系,公司决定开展远超单纯连通所有行星的额外工程。
为了使在“超空间™”高速公路上投入巨额太空资金显得确有必要,公司对“超空间™”高速公路网络施加了一条严格规则:只要存在一条不重复经过任何行星、且能从某颗行星出发并最终返回该行星的旅行路径(即一个简单环),那么该路径上所经所有行星两两之间都必须直接由一条“超空间™”高速公路相连。换言之,每个简单环所包含的行星集合,必须构成一个完全子图。
你正在设计一款“超空间™”导航应用程序,当前面临的关键技术问题是:找出从行星 A 到行星 B 所需经过的最少“超空间™”高速公路数量。由于该问题对 Bubble Cup 竞赛而言过于简单,现给出一个更难的任务:你的程序需对 Q 对行星分别求解上述最小值。
输入格式
The first line contains three positive integers N (1≤N≤100000), M (1≤M≤500000) and Q (1≤Q≤200000), denoting the number of planets, the number of Hyperspace™ highways, and the number of queries, respectively.
Each of the following M lines contains a highway: highway i is given by two integers ui and vi (1≤ui<vi≤N), meaning the planets ui and vi are connected by a Hyperspace™ highway. It is guaranteed that the network of planets and Hyperspace™ highways forms a simple connected graph.
Each of the following Q lines contains a query: query j is given by two integers aj and bj (1≤aj<bj≤N), meaning we are interested in the minimal number of Hyperspace™ highways one needs to take to travel from planet aj to planet bj.
第一行包含三个正整数 N(1≤N≤100000)、M(1≤M≤500000)和 Q(1≤Q≤200000),分别表示行星的数量、超空间™高速公路的数量以及查询的数量。
接下来的 M 行每行描述一条高速公路:第 i 条高速公路由两个整数 ui 和 vi(1≤ui<vi≤N)给出,表示行星 ui 与行星 vi 之间存在一条超空间™高速公路。保证所有行星与超空间™高速公路构成一个简单连通图。
接下来的 Q 行每行描述一个查询:第 j 个查询由两个整数 aj 和 bj(1≤aj<bj≤N)给出,表示我们希望求出从行星 aj 到行星 bj 所需经过的最少超空间™高速公路数量。
输出格式
Output Q lines: the j-th line of output should contain the minimal number of Hyperspace™ highways one needs to take to travel from planet aj to planet bj.
输出 Q 行:第 j 行应包含从星球 aj 到星球 bj 所需经过的 Hyperspace™ 高速公路的最少数量。
输入输出样例
输入#1
5 7 2 1 2 1 3 1 4 2 3 2 4 3 4 1 5 1 4 2 5
输出#1
1 2
输入#2
8 11 4 1 2 2 3 3 4 4 5 1 3 1 6 3 5 3 7 4 7 5 7 6 8 1 5 2 4 6 7 3 8
输出#2
2 2 3 3
说明/提示
The graph from the second sample: 
第二个样例的图:
输入解题思路,AI测评打分。不知道怎么写?