ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1065. Frontier

efficient idea
Posted by Cuac!++ 7 Apr 2008 07:07
Hi!, i have gotten AC in this problem, but i have 0.093 secs, and im not well ranked on the best solutions table, i think the difficult part of this problem is to see which triangle have historical monuments inside, i did it with an O ( logM * M * N ) approach, do anybody have something better? i really would like to know how to get 0.015 secs or less. Thank you very much! Eric ( Cuac!++ ).
Re: efficient idea
Posted by hedrok 9 Apr 2008 00:09
Hi. I've got 0.015 secs. http://acm.timus.ru/status.aspx?author=34678&num=1065&refresh=no
My algo woks O(M*N + N^3).
Here is my idea:
i don't look which triangles contain historical monuments. i calculate which sequences of vertexes can we delete and what length we win if we do so. Then i find optimal way of selecting these sequences of vertexes.
Do you need more details?
Re: efficient idea
Posted by ASK 24 Apr 2018 00:12
Nope, it is at least O(M*N*log(N) + N^3), but with N~50 it is not noticeable.

For each tower check how many towers can be skipped, that is for each possible skipping length check if there are monuments ccw to the chord: O(M*N^2), but can be O(M*N*log(N)) with binary search.

For each length and each start calculate minimal perimeter on the way from start to start+length trying all intermediary towers: O(N^3).

For each triple of towers that form a triangle, sum minimal perimeters and find the global minimum: O(N^3).