Back to Problem Solutions forum
I don't see info stating the initial rainfall/water distribution. 1 unit of rain water over the entire grid? Or is it just asking, over a period of continual rainfall, what is the max capacity for water retained?
The problem's theme is the great flood, so I assume the latter, but it seems a little vague for no reason.
Also there doesn't seem to be a thread for this problem on the forum, so anyone may use this in the future for that purpose.
Quote: "Rain was so heavy that water level raised and covered even the highest peaks."
Alright yeah that's what it wanted
Guys, I went through hundred times up and down but I can figure it out. Could you please check my codes? I manually check the solution, and I feel it correct. I am tiered now :-)
Sam, Hi!
I don't remember quite well, but probably this task isn't quite trivial and requires some subtle logic to be employed and implemented... "check my codes" regretfully doesn't always help as your source doesn't immediately reveal the logic at all (to stranger it looks rather cryptic I'd say - writing well-readable code is a separate art).
So generally you'd better describe your idea of solution verbally if you would like to verify it's correctness.
Judging by your program having only 2 loops, I suspect the program is doing something different rather than solving this precisely task. It's simply couldn't be enough if I understand correctly. I suspect logic should be more complex. I don't mean the program should be larger, though :)
Probably the best way should be not trying too advanced problems until you gain enough skill. On the other hand you probably feel already that straightforward "childish" tasks are dull for you. So I recommend picking tasks by tag dynamic programming, graphs, and puzzle for example. In that way you probably can build your experience most effectively.
Hi Rodion,
Thanks for the suggestion. I am desparate to finish this. I got the correct answer for the example test case but not for the problem.I feel that I have misinterpreted the problem statement.
Need a favor, appreciate, if someone can run this grid and tell me the answer with the result grid (Just like the example in the problem)
18 16 26 20 20 25
25 13 32 16 37 12
30 23 37 39 36 28
18 16 42 40 39 13
28 13 32 30 12 16
14 11 22 12 39 38
Cheers, Sam.
I think it's 11
. But why not trying to figure this out with pencil-and-paper? Such approach may enlighten you on the
proper algorithm...
Yes I did, :-), but i need to check the fill pattern, since, my answer to the example data set correct but with the data set of the problem, the answer is wrong. cheers, sam.
Hm-m-m... that's embarrassing... Let's check my calculations:
18 16 26 20 20 25
25 (13) 32 (16) 37 12
30 23 37 39 36 28
18 16 42 40 39 13
28 13 32 30 (12) 16
14 11 22 12 39 38
The water should remain seemingly in the 3 locations marked with parentheses. 3
on 13
, 4
on 16
and 4
on 12
...
But this is not the most difficult example. Regard this one also:
18 17 26 20 20 25
25 13 16 15 37 12
30 23 37 39 36 28
18 16 42 40 39 13
28 13 32 30 12 16
14 11 22 12 39 38
The difference is I tried to make water stay on row of three cells 13-16-15
.