Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Signup with
Have you tried CodeChefs "Code, Compile & Run" Its pretty cool. Try it out by pressing Ctrl+; and
typing "ide" [X]
Treasure Hunting
ALL SUBMISSIONS SUBMIT
Problem code: N1
Like Share 18 people like this. Sign Up to see what your
friends like.
The N following lines describe the maze. The meaning of the symbols is as follows:
lifeofpie 0.06 3.1M C++ 4.3.2 View
'.' : an empty square
'*' : a treasure goutham7_4 0.06 3.1M C++ 4.3.2 View
'#' : a blocked square
sandeep_sandha 0.06 3.1M C++ 4.3.2 View
The number of treasures in the maze does not exceed 13. Squares (1,1) and (n,n) are always empty.
Each test case's input is separated by a blank line. akashrawat 0.06 3.5M C++ 4.3.2 View
Output
hariram 0.07 2.5M C View
For each test case, print in a single line the earliest time that Dave can reach the destination after
collecting all the treasures. If Dave cannot reach the destination, print -1.
cyb3rpunk 0.07 2.5M C View
Example
Input:
4 1 of 7
3
...
.##
*#. HELP
3
..*
...
...
3
..*
*..
...
4
....
.#.*
.#*.
**#.
Output:
-1
4
6
16
Author: admin
Date Added: 5-02-2010
Time Limit: 2 sec
converted by W eb2PDFConvert.com
Source 50000 Bytes
Limit:
Program should read from standard input and write to
ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.8.1, CPP11, standard output. After you submit a solution you can see
Languages: CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, your results by clicking on the [My Submissions] tab on
NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2,
RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC the problem page. Below are the possible results:
The problem description does not mention a blank line before each test case, but the sample has a
blank line before each test case. Does the input actually have a blank line before each test case?
@Manuel G. Araujo A.
the answer is -1 for ur case since before reaching destination u have to pick all treasures!
but in your case it is only possible to get treasure after passing the final destination.
@ kaushik
you are completely wrong. Ans would be 6 in this case.
hi Gunjan,
I appreciate your attempt but would u please explain what is going on in solve function with example
puchica, that kind of input does not occur in the judge data. I tested my program in both ways (output
of -1 and 6 for your test case), and both were accepted.
ripudaman22, I solved this with a Breadth-first search. I only add an element to the queue if it has not
been previously visited with the same treasures collected.
I need help to solve it--pls tell me relevant concepts or algo that I should read to solve this. !!!!!
converted by W eb2PDFConvert.com
s_wrapper @ 24 Feb 2013 07:49 PM
Same here. Can anyone please add tutorial for this problem ? Or atleast tell how to solve this
problem ? That would be a great help !
4 .... .#.* .#*. **#. path for this case can be 0,0 -> 0,1 -> 0, 2 -> 1,3 -> 2,2 -> 3,1 -> 3,0 ->2,0 ->1,0 ->0,1
->0,2 ->1,2 ->2,3 ->3,3 ???? as we can move diagonally and we have to find the minimum.......by this
way it is 13 hops. Do answer!!!!!
can you please give more test cases or if you can explain no. 4
Question, i submitted a code that run in 4ms on my PC and return the expected output, but I receive
an "Time Limit Exceeded". How can I investigate ? Is there a way to have a look at the execution log ?
Because I don't understand my code can run in more than 3sec .... what kind of server/pc run tests ?
For anyone looking for path-finding algorithms to solve the question , you might consider taking a
look at this interesting article that describes in great detail how to go about solving such problems.
Mind you, it doesn't spoon feed you the solution, just gives pointers for any non-cs majors out there.
http://www.policyalmanac.org/games/aStarTutorial.htm
Editorial please???
converted by W eb2PDFConvert.com