All submissions for this problem are available.
Chef loves to watch Takeshi's Castle. He especially enjoys watching the 'Skipping Stones' segment of the show. He has created a similar game that has players cross a river by skipping on stones. Now here's the catch, a player can only step onto a stone if that particular stone can support his/her weight. Also its given that the first and the last stone will always have sufficient weight to hold the weight of player.
For a given scenario, the player would only know which stones would hold his/her weight and the paths through which he/she can travel. So, tell us, whether the player can cross the river. YES or NO!
The first line of the input contains an integer T, denoting the number of test cases.
The first line of test case consists of number of stones - N, number of paths - E, weight of the player - Wt.
Next line consists of N spaced integers which denotes the weight of stones 1,2,..N.
Next E lines consists of path of one stone to another stone, through which player can travel!
For each test case, output a single line in format Case #T: answer, where answer will be YES or NO, that is if player can cross or not respectively!
1 < T < 10
5 <= N, E <= 10
10 <= Wt , Wi <= 50
5 5 20
20 30 10 40 20
3 2 10
10 9 10
Case #1: YES
Case #2: NO
EXPLAINATION: In first test case, player can travel from 1->2->4->5, whereas, in second test case, he cannot travel as in path 1->2->3, 2nd stone cannot handle the weight of player.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions