> "real matrix is 50000*50000" HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa
It's not that impossible if the approach was mathematical.
Of course this would require cleanly defined rules and not these "oh good point I forgot to mention that ..." dialogs.°
How this?
- I could imagine proving that
a path covering n-x points is maximal possible and exists.
- One would identify the x minimal points to be excluded.
- I expect x to be just the non positive weight cells in most cases anyway.
- There are most likely many equally short paths possible, which could be proven, too.
- Now picking one minimal path should be sufficient.
In short, no need to brute force all possible paths if there are plenty optimal ones and picking one is sufficient.
Of course I might have misunderstood the "rules", but why should I risk to invest more efforts for vain ? ;)
For instance:
- is it really allowed to slide back a way you just slid forward? (Like your first two moves a0-up9-down3)
- is it allowed to slide over positive weights? (Like your third move -left1 ignoring 3 positive cells in between)
°) read "I have no real clue what I need"
update
Your solution demonstrates my approach pretty well:
- you are visiting all positive cells
- the only non positive one is your starting point
- the shortest path must have the same amount of moves when you avoid revisiting a cell.
- There are certainly many paths meeting that criterion
- most probably automatically constructed from smaller segments like: "finish a column/line before switching to the next one"
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|