Pagini: [1]   În jos
  Imprimă  
Ajutor Subiect: Balance  (Citit de 5364 ori)
0 Utilizatori şi 1 Vizitator pe acest subiect.
Cosmin
Echipa infoarena
Nu mai tace
*****

Karma: 351
Deconectat Deconectat

Mesaje: 1.799



Vezi Profilul
« : Iulie 29, 2015, 09:40:28 »

http://www.infoarena.ro/blog/balance
Memorat
chiriacandrei25
Strain


Karma: 5
Deconectat Deconectat

Mesaje: 8



Vezi Profilul
« Răspunde #1 : Iulie 29, 2015, 16:14:20 »

This problem was actually proposed in one of the latest Codeforces rounds. It is obvious that the Greedy algorithm is not good enough. The trick is to make a bipartite graph with the X-s coordinates of the points in one set and the Y-s in the other. Then we can add undirected edges from any x from the first set to any y from the other set as long as point (x,y) exists in input. If our resulting graph is eulerian, it's obvious that our problem is done, because we can color edges ( that are actually points from the input ) in white-red-white-red uniformly across the eulerian cycle we have. The problem is if we have nodes with odd degree. That can be really nice solved by adding 2 more nodes, one where we add edges between him and the x's nodes with odd degree and other node where we add between him and the y's nodes with odd degree. The question is : What if these 2 other nodes have odd degree now? We can easily notice that either both have odd degree , either both have even degree, so it is enough to add an edge between them in case the degrees are odd. And we have an eulerian graph. In this way, after coloring the eulerian path as I sad, every node has an equal number of white and red edges adiacent to him, so if we delete our fake 2 nodes we used to help us, the difference of colors is at most 1, and the problem is solved.  Smile
« Ultima modificare: Iulie 29, 2015, 16:20:04 de către Chiriac Andrei » Memorat
florin.elfus
Strain
*

Karma: 109
Deconectat Deconectat

Mesaje: 43



Vezi Profilul
« Răspunde #2 : Iulie 30, 2015, 01:20:31 »

Zaharel can also be solved with a similar idea Smile

Also, a problem of this type is E div1 from one CF round I proposed.

http://codeforces.com/contest/429/problem/E

Memorat
Pagini: [1]   În sus
  Imprimă  
 
Schimbă forumul:  

Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines