SEAGRP - Editorial

I used a similar approach.
I made a recursive function which took a source node and then if an edge existed with next node , then marked both vertices as visited. Then if(new source is available, i.e some unmarked vertex is present) recur with that node as source.
else if(no vertex is found that is unvisited) return true, i.e graph can be reduced
If one complete traversal results to no solution than backtrack(unmark the visited node and continue with the next one).

It may not be the best way but it worked!!
http://www.codechef.com/viewsolution/3191837

Read the wiki, and Xij = rand(), Xji = - Xij. if i < j and (i, j) is an edge.

What do you mean by “Due to the randomness, we can solve this problem with a high probability” …and also How to find determinant of matrix using gaussian elimination??Please tell.

@herman, if you perform the classic gaussian elimination, and if you put the matrix in Upper Triangular form, then, the determinant is simply the product of its diagonal.

@jaggi1234 & @ddhruvkr, i’m not sure if your assumption is correct but I’m pretty sure that it’ll fail in this case , Refer to the image and I’m sorry for the bad image :stuck_out_tongue:

alt text

Your Algo will remove the edge circled in blue , which disconnects the graph and it’ll result in a ‘NO’, but the answer is ‘YES’ !
If this case was included you both should’ve got WA :stuck_out_tongue: be glad you got AC :slight_smile: Cheers !!

2 Likes

@m_a_y_a, I’ve followed an algorithm similar to yours, except that when i encounter a cycle i do the following :

–> Check if the cycle has an articulation point,

–> If yes, then retain only the edge connecting the articulation point to ODD no of vertices and remove the other edges (if multiple edges with odd vertices are there , then select any one ) and then continue with your algorithm again,

–> If no, then just check how many vertices are there, if even then “YES” if odd then “NO”.
Thats pretty much it :slight_smile:

1 Like

Hi! I also used Havel-Hakimi theorem but also got WA… Used same idea as you did :slight_smile:

The randomness means Xij should be chosen randomly

@mecodesta Indeed, my algo will fail in that test case. Thanks for pointing it out!

First Things FIRST:

  1. Interesting problem (though a ready-made algorithm was available).

  2. Good that the problem statement did not mention any unwanted stuff like (no ODD cycles and all), else it would have been simple bi-partate matching.

  3. Tutte Matrix was a really interesting method.

Issues:

  1. I was on this problem for many days, trying to implement blossom’s algo flawlessly (Couldn’t succeed though). And eventually many brute-force and normal BP-Matching solutions passed, definitely due to lack of proper cases not because their algo is apt.

  2. Shangjingbo’s comment which says they couldn’t monitor all the solutions, wasn’t convincing. So if you can neither design proper cases, nor monitor solutions which get accepted with flaws, why frame a problem ? That was disappointing due to improper testing.

4 Likes

i can’t understand ,what your code is doing…(it’s unformatted) … please edit it so that it’d be readable…

@mbrc Can you please explain what are you doing in your above code.