My someone help me which test cases my code fails!! I almost checked every test cases!! 2017-05-27_1033
A possible solution would be to make these checks
- one of the endpoints overlap
- the two snakes are parallel and
- one of the snakes has an endpoint lying on the other
if either 1 or (both 2 and 3) are satisfied, then print yes
otherwise print no
This case gave me a huge amount of headache :
one snake is a line, and other one is a point, now if the point lies on the other snake , it satisfies both the conditions of being parallel to the other snake as well as being perpendicular to the other snake, and the answer it should give is yes, but if we check in case of perpendicular snakes, my code was giving no because i was checking endpoints.
Then i separately handled this case.
Here’s my solution //i am a newbie so my code may look like that
I have tried it a lot, but still, could not find a test case where my code goes wrong (getting a WA). Can someone please help me with a test case. I have tried all the cases mentioned above. Thanks.
My solution
https://www.codechef.com/viewsolution/13740189
Even if they are not overlapping but just connected by their end points they make a connected component as said in the ques
consider the test case:
2 1 8 1
1 1 1 7
and
2 1 8 1
8 2 11 2
Please tell me where am i wrong.
I guess you’re going wrong when both lines are horizontal.
Check for this input:
8 0 -2 0
9 0 6 0
The code would give wrong answer for above test case.
You need make cases as follows,
-
x22 <= x11 << x21 and x21 <= x11 <= x22
-
x22 <= x12 << x21 and x21 <= x12 <= x22
-
x11 <= x21 << x12 and x12 <= x21 <= x11
-
x11 <= x22 << x12 and x12 <= x22 <= x11
to avoid above tedious checks, you can do this:
if(x11 > x12) swap(x11, x12);
and if(x21 > x22) swap(x21, x22);
and then apply your checking conditions(written in your code).
Hopefully you get it!
Your code gives WA in this case:
0 2 0 8
0 2 0 2
your code gives answer NO, while the answer should be YES.
Thanks @sumedhk and Yes, my code was surely going wrong on your given case.
Well I did made changes as per you suggested…but it’s still giving WA…
Please help…!
PS: Code link is as stated above in my answer
@sumedhk Can you provide a test case for my code also?
https://www.codechef.com/viewsolution/13729968
Here’s a test case where your code fails:
0 2 0 6
0 6 0 7
Answer should be YES.
May be you can take a look at my code:
[1]
[1]:https://www.codechef.com/viewsolution/13671836
Yess, I got it but I am still not able to get what is going wrong in my code…! Is there any way I can see that test-case like we can do in CF…?
I am getting correct answer even in this case. From past two-three days I am not been able to find out where I am getting wrong. Here is Link of my solution.
Can you help me out please. @shashank96 @sumedhk @jeetu86044
the original test case is: 1 2 4 2 -1 2 -8 2
@the_king_i_am ,the answer should be no in the test case given by you. And mine is also printing yes.
Thanks for the concern.
@the_king_i_am ,the answer should be no in the test case given by you. And mine is also printing yes.
Thanks for the concern.
where is the link?