- UID
- 1767
- 斋米
-
- 斋豆
-
- 回帖
- 0
- 积分
- 297
- 在线时间
- 小时
- 注册时间
- 2010-5-5
- 最后登录
- 1970-1-1
|
求路过的大哥大姐大妈大叔萝莉御姐女王水王大圣给下这题的思路 , 小弟将不胜感激涕零Orz加内牛满面中
8 F5 i" P1 P h) `9 ~; [" _1 ^! M6 Q. F4 x+ C* W+ [
Problem Description: ~* h1 Z& R* w' G$ E5 V9 \6 b
2 q) s$ V! C5 a4 F1 G. Z
Alice and Bob are going on a trip. Alice is a lazy girl who wants to minimize the total travelling distance, while Bob as an active boy wants to maximize it. At the same time, they cannot let the value to be less than a given integer L since that will make them miss too much pleasure, and they cannot let the value to be greater than a given integer R since they don't want to get too exhausted.
( g# J5 R8 g) IThe city they are visiting has n spots and the spots are connected by directed edges. The spots are connected in such a way that they form a tree and the root will always be at spot 0. They take turns to select which edge to go. Both of them choose optimally. Bob will go first.: m; ], I9 y: Q8 j
7 m1 |) r8 P& s& r3 D& l- l
, i6 N0 N1 A2 \7 V7 ]+ A2 F8 d1 e O. v; V
/ J+ \! t9 `( I9 f7 t; [ X
Input0 c% ^' a( i; J# e! K
X: z+ W+ o% _$ U3 ], e3 P3 S9 M! ]/ L
There are multiple test cases. For every test case, the first line has three integers, n, L and R (1<=n<=500000, 0<=L, R<=1000000000). The next n-1 lines each has three integers a, b and c, indicating that there is an edge going from spot a to spot b with length c (1<=c<=1000). The spots are labeled from 0 to n-1.' {# I( a- R+ ~% P& I: E$ o
There is a blank line after each test case.7 B& W3 p- I+ I2 I8 T
Proceed to the end of file.4 q+ R" \7 V) Z* u
6 s: e# ~, H8 B) d; E
" R# ^) v4 j8 p! l8 t9 u3 Y" J5 x7 d/ L0 d# p' M' v
+ `- b7 d7 v1 L- r( z( O
Output
: Y0 f: F4 v! {1 V
# j P+ }! }4 E, |. P' K/ pIf the total distance is not within the range [L, R], print "Oh, my god!" on a single line. Otherwise, print the most value Bob can get. & Q+ F# n( W8 ]' c; `% e4 h; H/ o
6 n; G5 k4 ]! D
. q `# \8 ~1 {( f1 W2 V9 h8 N$ P$ r
Sample Input
$ I! g( s7 z3 A! `, o }: ]1 Y B
/ e2 ] N; _" z- o! Q/ ]3 2 40 1 10 2 57 2 80 1 10 2 11 3 11 4 102 5 12 6 57 4 80 1 10 2 11 3 11 4 22 5 12 6 54 2 60 1 11 2 11 3 5% R& `9 d5 u1 h. ?
7 [ t \" H4 A/ k' u
3 \( A; Z) ]$ \- u* T6 h# v9 |8 d3 A6 r
2 ?; d% |: t% U0 E9 w5 gSample Output7 m: q- z" O7 B
* _8 M, h& T8 @" P5 b1 F. B# gOh, my god!262
" s4 |& L s) T* s6 c! V
$ C" C* x* r' }' y |
|