WA in Smaller Subtask (CHAHG)

Guys I tried my best to debug it but I couldn’t :frowning:

It was failing for smaller subtask.

Can anyone provide me with a testcase for which my Code is failing.

Thankyou! :slight_smile:

Your code fails for this test case

7

7 2

7 5

2 8

8 7

2 0

8 0

2 9

Answer

0

Output

1

0 0

You can use test your code by generating random test cases ( like this ) and testing it against a correct brute force solution.

2 Likes

I have not read your code but here is one small test case where your code fails. link.

I also checked your code your correctness on large random inputs (10000000 test cases in number) but all worked fine. May be some base case may be missing which may not have been included in large test file it seems.

BTW, for the input given, your code gives

 1
 0 Inf 

as answer but the correct one is

 1
 1 Inf

we can even create bash script for doing the same, so that you can test your code on even your more of cases easily, instead of manually compiling and checking on your own again and again. Also a small output checker which compares output of files can be helpful.

Thanks @dushsingh1995 :slight_smile:

That testcase really helped. Got mistake and debugged too!

Here’s Ac Code

Mistake was - when h1 == h2 and m1 , m2 were satisfying the inequality I was assuming it as t > -1 instead of t > 0.

Since for t = 0, both will be equal.

Thanks @likecs :slight_smile:

Mistake was - when h1 == h2 and m1 , m2 were satisfying the inequality I was assuming it as t > -1 instead of t > 0.

Since for t = 0, both will be equal.

@likecs Offline judge system cool! :smiley:

//