How do I solve this DP problem? Notice the word "tunnel" in the problem statement which confused me. https://www.e-olymp.com/en/problems/5852

Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

# | User | Rating |
---|---|---|

1 | Radewoosh | 3443 |

2 | tourist | 3372 |

3 | OO0OOO00O0OOO0O0…O | 3264 |

4 | ksun48 | 3176 |

5 | scott_wu | 3168 |

6 | CongLingDanPaiSh…5 | 3157 |

7 | Benq | 3154 |

8 | Petr | 3139 |

9 | Um_nik | 3138 |

10 | LHiC | 3118 |

# | User | Contrib. |
---|---|---|

1 | Radewoosh | 195 |

2 | Errichto | 176 |

3 | rng_58 | 158 |

4 | Ashishgup | 157 |

5 | neal | 156 |

6 | tourist | 154 |

7 | Petr | 151 |

8 | PikMike | 150 |

9 | Um_nik | 149 |

10 | kostka | 147 |

10 | Swistakk | 147 |

10 | Vovuh | 147 |

How do I solve this DP problem? Notice the word "tunnel" in the problem statement which confused me. https://www.e-olymp.com/en/problems/5852

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/11/2018 17:48:32 (d3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

How the word ``tunnel'' can confuse???

DP subproblems should be:

"What minimal distance magus should walk to get from start vertex to vertex.#i, using not more thanjbridges?"I think tunnel means that no 2 bridges can intersect. Yes, i figured out that dp. It will be kn^2 right.

I implemented the DP you told but I got WA.

A typical mistake solving this problem is to consider (incorrectly!) that no returns can be useful. Sometimes they may be. For example, look picture at the top of page 195 of http://ws.kh.ua/media/sbornik/Sbornik2010.pdf, assuming that

K= 2 (only two bridges are allowed), neither AE nor FJ bridges are allowed because they intersect surface near C and near H respectively, and neither AJ nor AH nor CJ bridges are allowed because each of these segments' length is greater thanR(maximal length of bridge).(That book is in Russian, but you may at least look at the picture and at equations.)

Which bridges are not allowed? 1) Those whose distance are more than R 2) Those which intersect the line formed by joining the points

Am I correct?

Yes, except that

`some points or segments of the bridge can touch the surface of the earth`

.In other words, bridge cannot go under earth surface (polygonal chain), but some vertice or some segments of polygonal chain may belong to some bridges. For example, if we have polygonal chain

and

R≥ 4, we may build a single bridge from`0 10`

to`4 10`

, although the bridge comes through`2 10`

So bridges need to be straight lines?

Yes

How do you assure that the bridge doesn't intersect earth in your DP?

This question was duplicated in http://codeforces.com/blog/entry/59717

This looks like this problem is used in some current contest, so let's wait for some days before further answering.

Well, it's not from any recent contest but okay we can wait for a week maybe if it's fine with you.

Hey! I am still unable to solve the problem can you please help!!

Now?

Well, AFAIK it's much more efficient not to check does given bridge intersect surface, but to build graph of all possible bridges in a special algorithm stage before (main) DP stage. In this way, it's quite easy to build all

O(N^{2}) bridges totally in Θ(N^{2}) time andO(N^{2}) space.For example, to build all possible bridges from vertex

v_{1}(1-based), one can maintain "current maximal slope" (let's name it`maxSlope`

). It's initialized asv_{1}v_{2}vector (`vector(v[1],v[2])`

in notation of pseudocode below); then,H-m, it looks like

checkingof this problem at e-olymp.com is incorrect. Try at ejudge.ckipo.edu.ua, contest #16 "Upsolving of Ilya Porublyov's and DrPepper's day of ISSPS'13 // Дорешивание дня Ильи Порублёва и команды DrPepper ISSPS'13", problems F and G respectively (F for smaller constraints, G for full). (There are no English-language statements at that site, but one can switch its interface to English.)I've already sent bug report to e-olymp.com admin, but still have no reply for it.

Thanks, I fixed it. Enjoy!

P.S. I did not retest all solutions, who got 0 points, please send again your solution.

thanks!!