How to solve Code Wars 3.0 COW3G?

I did it without any logic and seriously I don’t except AC
its just hit and trial method without any logic

1 Like

How to solve the last one?

OK, so you need to observe that at any time the number of RIGHT moves need to be greater equal to the number of DOWN. (Or the reverse). So it boils down to number of good bracket sequence problem.

I think you’ll take it from here. The answer is just \frac{2}{N}

1 Like

Number of correct bracket sequence is nth Catalan number. How to transform that to probability specifically coming to (1/n).

So, if the dimension is NxN. Then total RIGHT is N-1 and total DOWN is N-1. So total ways is C(2N-2,N-1).
Out of those, Good paths are 2\times\frac{C(2(N-1),N-1)}{(N-1+1)}, one for Right Greater and one for Down greater. Dividing these two is just \frac{2}{N}. But they asked bad ways so you can just subtract by 1.

1 Like

Thank you :slight_smile:

1 Like

can you share your approach for simple lcm.

i mean the correct approach for this problem.

I couldn’t solve that during the contest. I’m also looking for the same.
Though I am almost convinced that taking around 100 or 1000 of the biggest distinct numbers and checking them with the rest is a correct approach.

That’s not the only issue, check out this problem Problem - F - Codeforces

4 Likes

Check out the editorial of problem F

3 Likes

Thanks a lot for sharing this, so it was supposed to be the hardest problem of the contest (which it failed to be, unfortunately :sweat_smile: )

2 Likes

Yep :confused:

I think the setters have updated the testcases.
The old solution doesn’t get accepted anymore. Now, it’s giving wrong answer.
Now we really have to optimize and think of a real solution!!

1 Like

I was trying to solve COW3G question but I was getting TLE again and again then I took help from an already accepted solution but still I was getting TLE so I got frustrated and just copied the AC solution of one another’s code and submitted it but again I got TLE.
can anyone help me, please.
both code are same with different verdict
AC solution
TLE solution

help please
both code are same with different verdict
AC solution
TLE solution

The testcases have been updated, the testcases for the problem during the contest were weak , it was a huge mistake and we are truly sorry for that. The editorial with setter’s solution and the true approach will be uploaded soon.

1 Like

I think the idea was to find two numbers whose product is maximum and gcd is minimum.
i.e numbers which has least amount of common prime factors and greatest product, but it’s only a partial answer.

This is happening because the setters have updated the testcases and due to that the earlier accepted solutions which were not optimized may not get accepted anymore!!

Will previous solutions during the contest be rejudged ?

thanks please upload editorial ASAP.