PLANEDIV - getting WA

c-plus-plus
dec15
gcd
hash-map
map
planediv
sets

#1

Hi,

I’ve submitted the solution for the problem PLANEDIV, but am unable to figure out the problem in my code as it is getting rejected. I’ve created a set object and have stored all the line coefficients in the set. I’ve also overloaded the < and > operators of the set, such that if there is a repeated line with different a,b and c, it will not be added to the set. Then I use a map to count the maximum number of lines in the set with the same slope. But still getting wrong answer. Any help would be appreciated.

Here is the link to my solution:

Here is a link for the problem statement:
https://www.codechef.com/problems/PLANEDIV

Thanks in Advance


#2

There are two mistakes in your code :-

  1. Your code doesn’t provide correct answer for test cases where N = 1, ex consider the test case :-
    1
    1
    10 20 30
    It should provide the answer as 1, but it is providing the answer as 0.

  2. You don’t take gcd of A,B as well as C. The number by which you have to divide the coefficients is gcd(A,B,C) not just gcd(A,B).