• [G] Grey Wolf Task

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • The village of sheep new-built many underground houses,these houses are distributed into a tree structure.each house has a number,from 0 to n-1.Number 0 is village head's house.paying attention to that every house only live a sheep.village head's house is the entrance(namely root node) of all the other houses.After that,each house up to two other house at most.the interval between the houses have different distance.

    Grey wolf listen to his wife's command to catch the sheep,he always forward at a speed of one meter per second,this lead to him sometimes can't finish his wife(Red Wolf) to his task.His wife will have many commands,that is to say,giving him different time and the number of sheep needed to catch.Your task is to judge Grey wolf whether can complete the task or not.

    Noticing that due to catch the sheep at night,so as long as Grey wolf into sheep room,he will can catch the sheep.


  • 输入
  • The first line given three integers:n(0<=n<=500), q(0<q<=100000), d. standing the number of village head's room,the number of Grey wolf's task and the distance between Grey wolf and sheep vliiage(meter).
    The next n-1 line.each line input three integers:a、b、c. standing that the interval from room a to room b is c meter.
    The next q line.each line input two integers:t、m .respectively said t second,m sheep,namely Grey wolf's wife to his task
    There are multiple sets of test data,when n=0,the input end.
  • 输出
  • Output q line,for each task,if Grey wolf likely to complete tasks,output "I love You",oroutput "Go to the hell".
  • 样例输入
  • 8 8 2
    0 1 4
    0 2 5
    1 3 7
    1 4 2
    4 6 3
    4 7 1
    2 5 9
    6 2
    6 3
    13 5
    50 8
    48 8
    0 1        
    35 7
    22 6
    0
  • 样例输出
  • I love you
    Go to the hell
    I love you
    I love you
    Go to the hell
    Go to the hell
    I love you
    Go to the hell
  • 提示
  • 来源
  • 加多宝凉茶
  • 操作

显示春菜