PLANEDIV - Editorial

The problem is just to use a stable sort to sort according to the intercept after that with slope, removing duplicates and reporting the maximal set.

The case where b=0, can be taken separately (slope infinity)…

My simple solution using sort : CodeChef: Practical coding for everyone

2 Likes

Easy implementation using a set or map can be done to remove the duplicates and using y = m*x + c form of line. Insert pairs of slope and intercept into the set and then count the pairs with same slope. Duplicates will be auto removed.
Std Map Solution Link

2 Likes

@kevinsogo I can’t access the setter and tester solutions. Its saying access denied

I tried this problem using calculating slope & intercept - using y = mx+c.

It still gives 1 WA in both subtasks.

CodeChef: Practical coding for everyone

Is this because of precision or is there any other issue ?

Providing testcase will be really helpful.

I tried this problem with sorting line using comparison function…bt it gave WA in some test cases…
https://www.codechef.com/viewsolution/8945683

can u give me some test case where my code is giving error…link text

Java solution by storing the slope in Map
https://www.codechef.com/viewsolution/8905572

I also tried something like sorting by slope, but without converting to float. Here is my solution. Could you help me identify the mistake?

let l1 : a1 x + b1 y + c1 = 0

l2 : a2 x + b2 y + c2 = 0

l1 and l2 are parallel if and only if a1/a2 = b1 /b2 != c1/c2 .

I just sorted the lines by coefficients a,b,c so that identical and parallel lines come successively.

if two lines are identical then a1 = a2 , b1 = b2 , c1 = c2

if two lines are parallel then a1 = a2 , b1 = b2 , c1! = c2

here’s my java solution : CodeChef: Practical coding for everyone

2 Likes

i just ran the authors solution in prctice link of the problem… in c++14…
giving wrong answer!!! :stuck_out_tongue:

https://www.codechef.com/viewsolution/8965354

can anyone plz tell me where my code fails

This is another example why I want the tests to be submitted after the contests. This is another task I can’t solve because I can’t find the error in my solution :\ I tried writing a test generator and a slow correct solution, but everything is ok for small tests :\ When I ask for help the setter won’t help :\

I’ve used y=mx+c line equation and used cmp() function for sorting. Can anyone tell me the test cases where my solution fails.
https://www.codechef.com/viewsolution/8929449

Setter’s and Tester’s solution showing WA in all the test cases… :expressionless:

My solution gives RE (SIGSEGV) for 2 test cases please sm1 cud explain.
thanks in advance :slight_smile: CodeChef: Practical coding for everyone

Author’s Solution is giving wrong answer in all cases
please fix your code @author :slight_smile:
Good editorial. Thanks

3 Likes

What’s the bug in setter’s solution? :frowning:

Do we really need to consider the case of a vertical line? The statement states that “For a line with coefficients A, B and C either A or B is not zero”. So when B can not be a zero then how it is possible to form a vertical line?

I think I had the same problem like you at some point. So, if I understand correctly, your idea is to sort all the lines and check how many lines are next to each other and are parallel, but not equal?

Ok, I can’t give you a specific test currently, but imagine the following situation. After you sort the lines you have got a, b, c, d, e, which are all lines. And c == d, i.e. they are the same line. but b || c || d || e, i.e. b, c, d, and e are all parallel. Then the answer should be 3, right? But your code will stop at d, because it is the same line as c and it will produce the answer 2.

The only error I see is eventually of the error precision of the double. Did you try to write some test generator and a second slow-but-correct solution to test it? I can send you mine, if you would like.

yes please provide the link to your solution…