Блог пользователя pk842

Автор pk842, история, 7 лет назад, По-английски

P1 P2 P3 P4

As the round is over, the links are disabled by them.

I can only come up with a very basic brute force solution of $$$(2*N)!$$$ where for each of the order of visiting I calculate the cost and then update the answer accordingly. But as expected this even didn't pass even a single test.

Can someone please help me with some spoilers on how to proceed further with it?

Thanks!

Edit: Hello all! Why everyone is downvoting the post? Is there something wrong with it or I asked the question in a wrong way ? I find the problem difficult so I asked for help and if someone find it easy then instead of directly downvoting please explain the solution (or atleast a step towards it) and then downvote if you think it's irrelevant.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by pk842 (previous revision, new revision, compare).

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

I think an algorithm for this can solve hamiltonian path problem. So I don't think that a polynomial time solution exists.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

goes to all K cities one by one

if this means the cities should be visited in the order it is given in input then polynomial time algorithm does exist.

There are some inconsistencies in the statement, for example: the input description says there will be K integers in K lines, but sample gives all K integers in single line.

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Off-topic : Were you eligible(exp.-wise) for interview or appeared in contest just for fun ? It was mentioned that this contest was for experienced candidates, so I didn't participate.