ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

2.9(Clear Cold Water)

2022-02-09 21:31:48  阅读:234  来源: 互联网

标签:pipe distance Clear 样例 管道 Water 2.9 pipes barn


http://noi.openjudge.cn/ch0306/2392/

描述

The steamy, sweltering summers of Wisconsin's dairy district stimulate the cows to slake their thirst. Farmer John pipes clear cold water into a set of N (3 <= N <= 99999; N odd) branching pipes conveniently numbered 1..N from a pump located at the barn. As the water flows through the pipes, the summer heat warms it. Bessie wants to find the coldest water so she can enjoy the weather more than any other cow.

She has mapped the entire set of branching pipes and noted that they form a tree with its root at the farm and furthermore that every branch point has exactly two pipes exiting from it. Surprisingly, every pipe is exactly one unit in length; of course, all N pipes connect up in one way or another to the pipe-tree.

Given the map of all the pipe connctions, make a list of the distance from the barn for every branching point and endpoint.Bessie will use the list to find the very coldest water.

The endpoint of a pipe, which might enter a branching point or might be a spigot, is named by the pipe's number. The map contains C (1 <= C <= N) connections, each of which specifies three integers: the endpoint E_i (1 <= E_i <= N) of a pipe and two branching pipes B1_i and B2_i (2 <= B1_i <= N; 2 <= B2_i <= N). Pipe number 1 connects to the barn; the distance from its endpoint to the barn is 1.

输入

* Line 1: Two space-separated integers: N and C

* Lines 2..C+1: Line i+1 describes branching point i with three space-separated integers: E_i, B1_i, and B2_i

输出

* Lines 1..N: Line i of the output contains a single integer that is the distance from the barn to the endpoint of pipe i

样例输入

5 2
3 5 4
1 2 3

样例输出

1
2
2
3
3

提示

INPUT DETAILS:

The input above describes this pipe map:

                    +------+
                    | Barn |
                    +------+
                       | 1
                       *
                    2 / \ 3
                         *
                      4 / \ 5



OUTPUT DETAILS:

Pipe 1 is always distance 1 from the barn. Pipes 2 and 3 connect directly to pipe 1 and thus are distance 2 from the barn. Pipes 4 and 5, which connect to pipe 3, are distance 3 from the barn.

翻译:

描述

威斯康辛州奶牛场闷热的夏天刺激着奶牛去解渴。农夫约翰将清澈的冷水注入一组N (3 <= N <= 99999;N奇数)分支管道方便编号为1..从谷仓的泵里取氮。当水流过管道时,夏天的热量使它变暖。贝茜想找到最冷的水,这样她就可以比其他奶牛更享受天气了。

她绘制了整个分支管道的地图,并注意到它们形成了一棵树,根在农场,而且每个分支点都有两个管道出口。令人惊讶的是,每根管子的长度恰好是一个单位;当然,所有的N个管道都以这样或那样的方式连接到管道树。

给定所有管道连接的映射,列出每个分支点和端点到仓库的距离。贝西会用这个列表找到最冷的水。

管道的端点(它可能进入一个分支点,也可能是一个插口)由管道的编号命名。映射包含C (1 <= C <= N)个连接,每个连接指定三个整数:一个管道的端点E_i (1 <= E_i <= N)和两个分支管道B1_i和B2_i (2 <= B1_i <= N;2 <= B2_i <= N)。1号管道连接到谷仓;从它的端点到谷仓的距离是1。

输入

*第一行:两个用空格分隔的整数:N和C

*第2行..C+1:第i+1行描述了分支点i和三个用空格分隔的整数:E_i, B1_i和B2_i

输出

*线1 . .N:输出的第i行包含一个整数,从仓库到管道i端点的距离

样例输入

5个2

3 5 4

1 2 3

样例输出

1

2

2

3.

3.

提示

输入详细信息:

上面的输入描述了这个管道映射:

 +------+
                    | Barn |
                    +------+
                       | 1
                       *
                    2 / \ 3
                         *
                      4 / \ 5

输出详细信息:

1号管道离谷仓总是有一段距离。管道2和3直接连接到管道1,因此距离谷仓2。4号和5号管道连接到3号管道,距离谷仓的距离为3。

标签:pipe,distance,Clear,样例,管道,Water,2.9,pipes,barn
来源: https://blog.csdn.net/weixin_44746864/article/details/122849973

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有