hi,
could anyone please look at my code and tell me for which test case it fails, i am unable to find the failed test case.
This is my code, can some one point out the mistake please link- CodeChef: Practical coding for everyone
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_king_i_am
https://www.codechef.com/viewsolution/13750256
I canāt find anything wrong in it.
Plz help me find the bug. Appreciate it.
Thanks in advance.
Can anyone help me? I am unable whats wrong with my code:
My logic is:
if both are horizontal and y11==y21:
if (smaller x co_ordinate of each snake is smaller than larger x co-ordinate of other) :
print(yes)
else:
print(no)
My code is:
https://www.codechef.com/viewsolution/13766079
plz someone help me whats wrong with this smaller x co_ordinate of each snake is smaller than larger x co-ordinate of other BY THIS I MEAN IS :
if x11<x12 and x21<x22 then in order to overlap we must have: x11<x22 and x21<x12
Can someone, please tell me where did I go wrong? I am having really a bit of trouble with this simple code!
https://www.codechef.com/viewsolution/13740052
thanks in advance
@free_bird Your code is failing on test case 0 0 0 0 , 0 1 0 -1 as your answer is no
@kunwarpreet281 You are getting an error because you are printing extra new line before the answer
@amartya_bhatt You are failing test case 0 0 0 0,1 0 -1 0 .Correct answer should be yes but your are getting no
@babloo_1997 You failing both the test cases mentioned for free_bird and amartya_bhatt
@swamicoder You are failing the test case 0 0 0 -10,0 -5 10 -5.Remember not to use multiple relational operators in single statement as you have done in your code. For eg. for statement (i==j==k==l) ,when parsed your code will look like (((i==j)==k)==l) and now you can see very well why your code is failing. Happy coding
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