> "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"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.