zoukankan      html  css  js  c++  java
  • Housewife Wind(译)

    译文:
    题目描述
    在他们幸福的皇室婚礼之后,佳佳和岚隐居在XX村,享受着他们美好的婚后生活。XX村淳朴的村民都居住在漂亮的茅草屋中。一些小屋之间由双向道路连接。我们称有一条道路连接的两个茅草屋为直接相连。XX村有一个特别之处:从任一小屋出发,都可以到达其他所有的小屋。如果规定每条路不能被重复经过,那么任意两个村庄之间的道路都是独一无二的。

    在佳佳赚到了足够的钱之后,岚就正式成为了一位家庭主妇。
    他们的孩子很喜欢去找其他孩子去玩,想回来的时候,就会给岚大一个电话:“妈妈,接我回家吧”

    在不同的时间段,通过一条道路所需的时间也是不同的。
    例如,正常情况下岚走一条路需要5分钟,但是如果路上有一只可爱的小狗,可能就需要10分钟了(和ta玩耍是要花时间的),或者路上有一种莫名的味道,就只会花费3分钟。

    岚非常爱ta的孩子,所以ta很希望告诉ta的孩子们ta即将到达的准确时间。你能帮助ta吗?

    输入

    第一行包含3个整数n,q,s。表示有n个茅草屋在XX村,q个操作要处理,岚在茅草屋s。n < 100001 , q < 100001.

    接下来的n-1行,每一行包含三个整数a,b,w,表示有一条路直接连接了a,b,通过ta的时间需要w。 1<=w<= 10000.

    接下来的q行,每一行是一下两种信息之一:

    信息 A: 0 u
    一个在u茅草屋的孩子给岚打电话,岚应该从ta所处的茅草屋走到u

    信息 B: 1 i w
    通过第i条路所需的时间变成了w。注意时间的改变不会发生在岚走在路上的时候,改变只会发生在岚待在某个茅草屋等着接孩子的时候。

    输出

    对于每一条A信息,输出一个整数X,表示接到下一个孩子所需的时间

    样例输入
    3 3 1
    1 2 1
    2 3 2
    0 2
    1 2 3
    0 3

    样例输出
    1
    3

    原文
    Description

    After their royal wedding, Jiajia and Wind hid away in XX Village, to enjoy their ordinary happy life. People in XX Village lived in beautiful huts. There are some pairs of huts connected by bidirectional roads. We say that huts in the same pair directly connected. XX Village is so special that we can reach any other huts starting from an arbitrary hut. If each road cannot be walked along twice, then the route between every pair is unique.

    Since Jiajia earned enough money, Wind became a housewife. Their children loved to go to other kids, then make a simple call to Wind: ‘Mummy, take me home!’

    At different times, the time needed to walk along a road may be different. For example, Wind takes 5 minutes on a road normally, but may take 10 minutes if there is a lovely little dog to play with, or take 3 minutes if there is some unknown strange smell surrounding the road.

    Wind loves her children, so she would like to tell her children the exact time she will spend on the roads. Can you help her?
    Input

    The first line contains three integers n, q, s. There are n huts in XX Village, q messages to process, and Wind is currently in hut s. n < 100001 , q < 100001.

    The following n-1 lines each contains three integers a, b and w. That means there is a road directly connecting hut a and b, time required is w. 1<=w<= 10000.

    The following q lines each is one of the following two types:

    Message A: 0 u
    A kid in hut u calls Wind. She should go to hut u from her current position.
    Message B: 1 i w
    The time required for i-th road is changed to w. Note that the time change will not happen when Wind is on her way. The changed can only happen when Wind is staying somewhere, waiting to take the next kid.
    Output

    For each message A, print an integer X, the time required to take the next child.

    Sample Input
    3 3 1
    1 2 1
    2 3 2
    0 2
    1 2 3
    0 3

    Sample Output
    1
    3

  • 相关阅读:
    python之路----初识面向对象(二)
    python之路----初识面向对象
    python之路----包
    python之路----模块与序列化模块
    python之路----模块调用
    python之路----常用模块二
    Python之路----递归函数
    Python之路----内置函数
    【CSS】整屏大背景
    【PHP】打印输出var_dump+echo+print_r
  • 原文地址:https://www.cnblogs.com/wutongtong3117/p/7673313.html
Copyright © 2011-2022 走看看