Can anyone point out why I got WA for this solution of SAMESNAK? I am just not able to figure out where I went wrong in this: CodeChef: Practical coding for everyone
Some details of the solution:
swapper() ensures that a1 and b1 coordinates occur before a2 and b2 respectively.
in_range() checks whether the given value lies between 2 values (used for the case where they both belonged to a single row or column).
linear_checker() checks for the case when both of them lie in a single row or column(uses in_range).
row_column() checks for the case when one lies in a row and another in a column. Just checked the end points of the snakes here.
Can anyone point out why I got WA for this solution of SAMESNAK? I am just not able to figure out where I went wrong in this: CodeChef: Practical coding for everyone
Some details of this solution:
hoanvi(int a, int b): swap a and b;
giaonhau(int a, int b, int c, int d): if [a,b] and [c,d] overlap, return 1 else return 0
Wait, what do you mean by “correct output”? If i am not wrong, the snakes here intersect as “|-” (T rotated by 90 degree anticlockwise). Here the vertex (0,50) is of degree 3 and hence a no has to be printed. Can you please show me your perspective/PoV so we can clarify it further?
Thanks a lot @vijju123 . It was a connection issue due to which the comment got posted later .I was talking of the case which you pointed out for another user .
Please get rid of those excess whitespaces. It becomes a headache for the person trying to fix/debug your code. Nobody would want to help if its inconvenient.
Your code prints correctly for if i change “5 2 -1 2” to “5 2 1 2”, but prints wrong answer other than that (if that value is <1, eg- 0,-1 etc.). I believe its a case of complete overlapp of snakes. Look into it.