×

CONPOIN - Editorial

Author: Pavel Sheftelevich
Tester: Mahbubul Hasan and Sunny Aggarwal
Editorialist: Balajiganapathi Senthilnathan
Russian Translator: Sergey Kulik
Mandarian Translator: Minako Kojima

Hard

PREREQUISITES:

Maximal planar graph

PROBLEM:

You are given N points and M edges connecting them. You have to determine whether it is possible to draw those N points and M edges on a plane such that no two edges intersect except at the endpoints and it is not possible to add another edge without intersecting an existing edge.

EXPLANATION:

The first part is to find whether it is possible to draw the points and edges such that the edges are non intersecting. That is the definition of planar graph.

The second part of the condition is that if we add one more edge the graph will be non planar. Thus we have to find out whether the given graph is a maximal planar graph or not.

This can be done in linear time using the algorithm given here.

Time Complexity:

$O(N)$

AUTHOR'S AND TESTER'S SOLUTIONS:

This question is marked "community wiki".

75542742
accept rate: 77%

 2 @Amlesh, no, you can add one more edge, just draw a triangle and point inside it connected to all vertices of triangle. @tapasjain01, yes your algorithm should receive 20 points, because when n <= 5, only non-planar graph is K5, which is has more edges than 3*5-6/ answered 15 Jun '15, 15:41 6★madiyar 21●1 accept rate: 0%
 2 I agree with @Amlesh. This is the fcking shittiest problem statement I have ever seen in my life. To think I spent days trying the wrong problem when I have so much more important shit to do, darn. You guys do not know how to write problem statements. The question clearly wanted an embedding of a planar graph on the plane such that any new edge intersects a previous segment. Now, it is like, "Hehe, just a misunderstanding, I meant a maximal planar graph. Not a big deal". I hate you all. answered 15 Jun '15, 18:58 6★xorfire 136●3 accept rate: 14%
 1 IMHO the problem statement is misleading, since as its stated we aren't quite looking for maximal planar graphs. Consider the following input: 4 5 1 2 2 3 3 4 4 1 1 3 One way this can be interpreted is as a square with one of its diagonals connected. This is a planar embedding of a graph where no additional edge can be drawn, but however this graph is not maximal. As stated, the problem is to determine whether there exists a maximal embedding of the given graph (if its planar of course), and not just determine if the graph itself is maximal. In fact I noticed a lot of the AC solutions miss the above case. answered 15 Jun '15, 15:21 4★Amlesh 239●3 accept rate: 0%
 1 Please update the link to the Contest problem answered 15 Jun '15, 15:44 33●4 accept rate: 0%
 1 @madiyar the problem statement clearly states that we are to "try to place the given N points and M non-intersecting segments that are given, you will never be able to place M+1th segment". So for the input I described in my post, we can clearly embed the graph as a square with only one diagonal drawn, making it maximal. What the problem setter intended was to show that regardless of how the graph is embedded that it should be maximal, which isn't how the statement is currently worded. answered 15 Jun '15, 15:45 4★Amlesh 239●3 accept rate: 0% My interpretation of the statement "The question is: whether it's possible to choose N points on the Euclidean plane in any way such that they will always fit the situation described above" is that if there is at least one way of choosing points such that it does not conform to the conditions then answer is NO. The highlighted phrases are important. If you choose the points in ANY WAY, and they ALWAYS conform to the conditions, then answer is YES which is what the statement says basically. IMHO the statement is not ambiguous. (15 Jun '15, 20:48)
 1 But i won't choose these points. i would go for 1=(0,0) 2=(1,0) 3=(1,1) and 4=(0,1). So thats a possible way of choosing the points and hence the answer should be "YES" according to me. Because the question states "whether it's possible to choose N points on the Euclidean plane in any way such that they will always fit the situation described above." and YES, it is possible. answered 15 Jun '15, 15:50 106●3 accept rate: 0%
 1 @miteshag The question asks us to determine whether there exists an embedding such that we can't draw an extra edge. Yes I agree that this graph isn't maximal, but there exists a way to embed that graph so that there are no ways to add additional edges, namely a square with one of its diagonals. The problem statement should have mentioned that "regardless of how we place the N points on the plane such that the edges don't cross, we can't place a new edge between existing points", instead of "try to place the N points in a way such that ....". Its particularly frustrating because I immediately dismissed the idea of just classifying the graph as maximally planar precisely due to the fact that I thought the graph just had have one embedding that was maximal, as the problem statement suggests :( answered 15 Jun '15, 15:55 4★Amlesh 239●3 accept rate: 0%
 1 I attempted the question for 20 marks . This is my solution. http://www.codechef.com/viewsolution/7154533 It gave WA on the second part of the subtask meant for 20 points. Now , have a look at this solution, http://www.codechef.com/viewsolution/7211402 What i can't understand is that I just used a greater than sign for just namesake (in case there are more than n*(n-1)/2 segments given as the value of m). Afterall , it was specifically mentioned that no two points can be connected by more than 1 segment , and no point can be connected to itself. So, how can this solution of mine can be wrong. Pls, help where am I wrong. answered 15 Jun '15, 21:43 621●1●2●10 accept rate: 0% Case n=5, m=10 the answer is 0 while you are printing 1. (17 Jun '15, 16:07)
 0 @tapasjain01 @Amlesh For the case given with diagonal in a sqaure, we get to choose the points in cartesian plane.Hence, if I choose 1=(0,0) 2=(10,0) 3=(0,10) 4=(1,1). Then after making the graph, I can still add an edge, from 2 to 4. Hence answer will be 0. answered 15 Jun '15, 15:43 5★miteshag 31●2 accept rate: 0%
 0 I read it again just now. Now I see that your point is valid. answered 15 Jun '15, 15:55 5★miteshag 31●2 accept rate: 0%
 0 The problem statement changed to The question is: whether it's possible to choose N points on the Euclidean plane in any way such that they will always fit the situation described above. at 14/06/2015, 02:00 hrs IST. But I think it was too late. answered 15 Jun '15, 16:06 6★ushsh 1●2 accept rate: 0%
 0 I have had my time on this problem because of the misleading and ambiguous explanation. What I initially (and for several days) undertood was whether you can plot the N points in a plane such as no two intersect and adding one more STRAIGHT line would be impossible. There was a lot of red herring in the explanation: Why do the edges have to be straight? In no way does this change anything about the problem. What is with this sentence: "The question is: whether it's possible to choose N points on the Euclidean plane in any way such that they will always fit the situation described above." ? It has not much sense at all If the condition has to hold in any circumstance, WHY emphasize on the collinearity of the points? It makes no sense. This one drove me on the wrong track. Other than that, the problem was nice, and maybe I would have learned the algorithm for this one, if I had undertood it properly sooner. answered 15 Jun '15, 17:26 150●3 accept rate: 12% Edit: To clarify why the second point is a big contradiction to what the problem actually asks for: "whether it's possible to choose N points in any way(this was in bold)". Whether it's possible means that we should analyze whether there is at least one way of doing it, then "any way" messes up the logic. If you really meant looking for a maximal planarity testing, you should have said: "Whether, for any placement of the N points and M segments such as no two intersect, adding the M+1-th segment would break this property". This is much clearer and follows the rule of logic. (15 Jun '15, 17:31)
 0 Next time pay please more attention to the problem statement and clarify the updates somehow, otherwise people try to solve another problem which is much more complex. answered 15 Jun '15, 20:26 1 accept rate: 0%
 0 @shivamg_isc Check this :-- http://www.codechef.com/viewsolution/7234731 I just changed your soln a little bit.... All >= signs are there as it is except for n = 5 (last case) as 5C2 is 10.... That was your mistake for n = 5 and m = 9 ans is 1 and for n = 5 and m = 10 ans must be 0... Hope you can understand... answered 16 Jun '15, 00:20 1 accept rate: 0%
 0 @shivamg_isc , agree with you. As the problem statement says the given m edges are non-intersecting. For n=5, and the optimal planar graph will have 9 edges (i.e. we cannot add more edge). Since they are not giving non-intersecting edges they cannot give m>=10 for n=5, so for m<9 answer should be 0 and m>=9 answer should be 1. But it gave me wrong answer. I got correct answer for 20 points when i did m==9 instead of m>=9. Why so, if they haven't given m>=10 (because for m>=10 the m edges will intersect) ??? I mean answer should not depend for m>=10 for n=5 since they are not giving non-intersecting edges. Am i wrong anywhere in understanding anything?? answered 16 Jun '15, 00:26 51●3 accept rate: 8%
 0 @checkmate1 , Yes 5C2 is 10.But they cannot give m=10 for n=5 because for this the edges will intersect but question say the given m edges are non-intersecting. So how they can give m=10 non-intersecting edges for n=5??? So one cannot say whats the answer for m=10 and n=5. answered 16 Jun '15, 00:32 51●3 accept rate: 8%
 0 @shubham201 that is what.. this is exactly the point which flashed in my mind. It is impossible for them to give m=10 for n=5. Was there some problem with the test cases ? :/ .. This question sucks . answered 16 Jun '15, 00:46 621●1●2●10 accept rate: 0%
 0 Editorials are supposed to provide an opportunity for us to learn. Not point to a third party link! Wake up guys! answered 16 Jun '15, 22:19 21●1 accept rate: 0%
 0 Uploaded the paper (PDF) here: https://www.scribd.com/doc/269955060/A-simple-recognition-of-maximal-planar-graphs answered 29 Jun '15, 14:44 1★yleewei 84●1●4 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,482
×1,329
×1,197
×156
×2

question asked: 15 Jun '15, 14:15

question was seen: 4,985 times

last updated: 20 Jul '15, 00:32