CONPOIN - Editorial

PROBLEM LINK:

Practice
Contest

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

DIFFICULTY:

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:

Author’s solution
Tester’s solution

1 Like

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.

2 Likes

@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/

2 Likes

@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.

Please update the link to the Contest problem

1 Like

@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.

1 Like

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.

1 Like

@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 :frowning:

1 Like

I read it again just now. Now I see that your point is valid.

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.

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:

  1. Why do the edges have to be straight? In no way does this change anything about the problem.
  2. 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
  3. 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.

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.

The problem statement isn’t “misleading”, it’s entirely incorrect however you interpret it.

@ushsh, both the pre-edit and post-edit versions of the problem are wrong. The edit just rewrote the sentence while for the most part maintaining its meaning.

Easy example: for n=4, m=5, the graph can ALWAYS be drawn by choosing (it said you could choose points from the euclidean plane) the 4 points to be the vertices of a square and the 5 edges to be its outer edges and one diagonal, in which case you can never draw the 6th edge, making the answer 1 in this case. Every graph with (4,5) is isomorphic to the graph described in this embedding.

PRE-EDIT VERSION

… He marked N pairwise different points on the plane and then connected M pairs of these points by straight-line segments. None of these segments intersect(maybe except at the initial N points). Then Leha tried to draw the M+1-th segment but surprisingly it turned out that it was impossible to connect any pair of points by straight-line segment which wouldn’t intersect with any of the previous segments.
…
The questions is: whether it’s possible to choose N points on the Euclidean plane such that they will fit the situation described above.

Yes, it’s possible to choose points as described above. You said “is it possible to choose”. This means you are allowed to choose any planar embedding, even one that would prevent you from adding another edge.


POST-EDIT VERSION

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.

Yes, it is possible to choose points “in any way” (as described above) such that they will “always” fit the situation. “Any way” means “any one way out of all possible ways”. By saying “always”, the author obviously meant to say (as we realized after some WAs), output 1 if

(i) there exists at least one choice of points with a corresponding planar embedding, and

(ii) considering all graphs (>= 0 of them) resulting from an edge addition to the input graph, none of them has a choice of points corresponding to a planar embedding.

That is, is the graph maximal planar. Totally different question.

Making some words in a sentence bold does not change their meaning. Linguistic accuracy is the foundation of making problem statements, as all of mathematics and computer science depend on formal notation and on rigour in language.

I understand that the problem was probably translated from another language, but that definitely does not justify its being incorrect after testing. I know this is a pretty long rant, but I wasted a lot of time on this problem (as I did with the author’s previous problem LPARTY a few months ago, which also had a terrible choice of words and story).

I do hope I am correct and would appreciate it if someone could explain how I am wrong in case I am.

5 Likes

I used almost exactly the approach from the editorial - googled the paper and implemented the algorithm described there.

That’s a bad thing, though. For one, getting to the paper took me about half a minute on Google and 5 minutes of waiting for the login page on Researchgate to load. What’s worse, there’s literally no CS about it, it’s all just implementation and googling; you don’t have to read the paper (apart from the 3 algorithms you’re asked to implement) at all. That’s not how you make contest problems.

Btw “The first part is to find whether it is possible to draw the points and edges such that the edges are non intersecting.” - no, that isn’t required in the solution. From what I understood, the described algorithm is simple exactly because it assumes the graph is maximal planar, and just reports “fail” when the assumption fails instead of trying more sophisticated ways to test if it’s just planar.

Editorial: 0/10 nothing to read.

10 Likes

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.

2 Likes

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.

Could not download paper. Please write normal editorial or give working link.

4 Likes

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.

If you choose points in ANY WAY, and they ALWAYS fit the conditions stated (regardless of what points you chose), then answer is 1. (read my comment on @Amlesh’s second answer).

“the graph can ALWAYS be drawn by choosing (it said you could choose points from the euclidean plane) the 4 points to be the vertices of a square and the 5 edges to be its outer edges and one diagonal, in which case you can never draw the 6th edge, making the answer 1 in this case.”

Answer is 0 in this case. In your example, the graph cannot ALWAYS be drawn by choosing the points such that it’s a maximal planar graph

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.

1 Like