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

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

Hello :) from where I cant see solutions for problems that I hadnt solve , I want to ask solutions from peoples who solved this problems: 2015 ACM Amman Collegiate Programming Contest Problems :H,L . thanks :D

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

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

My solution for H:

First, find all bridges in the given graph, then remove them from the graph and find all components of the resulting graph.
Consider each component as a single vertex and add the bridges again, now you have a tree where all edges are bridges (in the original graph).
In the resulting tree, to make an edge not a bridge, it has to be in a cycle, and since all edges in this cycle won't become bridges anymore, you have to create the largest possible cycle, so find the longest path in the tree, and connect it's endpoints. Final answer is : Total number of bridges — length of resulting cycle + 1
Which is equal to : Total number of bridges — longest path in tree

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

H: build tree of biconnected components (2-edge-connected); after adding a single edge A-B to your original graph all bridges on path C(A)-C(B) in a tree (where C(X) is component in our tree which corresponds to X in original graph) will not be bridges anymore) Therefore you need to find such pair of vertices in a tree that distance between them is maximal, it can be done with two DFS. And you may not build a tree, but simply mark bridges in original graph and run Dijkstra instead of DFS. UPD. Or 0-1 bfs to reach better complexity, but Dijkstra also fits well :)

L: start with O(N^2) dp first. DP[i] — what is answer for prefix of length i. Transitions — try all possible positions of last cutpoint. Now let's improve it to NlogN. In order to reach NlogN it is enough to notice that valid cutpoints for position i form contiguous segment (except maybe one, i-1, which can be updated trivially). There should be "11" or "00" to the right from your cut (and this sets right border) and you can't cut at distance more than i-k (which sets left border). Now you should simply take minimum value among DP[l]...DP[r], which can be done with segment tree.

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

How to solve F.Travelling Salesman?

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

This is my F: Traveling salesman submission 11947059, I use Dijkstra with priority queue,Why I always get TLE, can any friends please view my code 11947059 and debug help me! :) It mean this code: http://ideone.com/uwgIxL

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

How to solve I?