Comments
+11

e.g. https://codeforces.me/blog/entry/7108 — in Java, if array is of primitive type, then Arrays.sort() will perform a quick sort under the hood, which is n^2 in the worst case for arrays that are almost sorted.

I guess because Arrays.sort() on primitive type array in Java has a known performance bottleneck and will TLE. A corresponding wrapper class should be used instead. At least my own solution was hacked because of that, sadly :(

On violentdoc → Who is rainboy?, 5 years ago
0

rainboy, is it you? :)

I am so depressed with a C ... It made me feel incompetent :(

if distance < r answer = 2 — could you please explain, why?

-8

First of all thank you for the article!

May I ask you a question regarding a Work for Robots task? You wrote:

Count the number of complete subgraphs. Nice and easy.

I tried to solve it using Bron-Kerbosch algorithm (I found all maximal cliques, then count), but the thing is that there are many overlaps between the cliques, which makes it hard (at least for me) to count the number of distinct complete subgraphs. Am I missing something? Could you please point me in the right direction? Thanks.

Because of precision errors, multiply X by 100 in the beginning to eliminate division.

+27

if you are registered — it's rated for you

and

one should be able to cancel the registration before the contest starts —

that's actually how leetcode contests work, which seems perfectly fine to me.

+21

I am in doubt this is a div2 round ...

Not the best solution, but probably might be easier to understand:

https://codeforces.me/contest/1472/submission/103314992

So you can use it as a base for a further optimization.

I think it might be easier to understand the logic using the following example:

A B
2 0
5 5
8 1

If we sort by A + B, we'll get:

A B
5 5
8 1
2 0

In this situation, in order to win the election, we need to make a speech in the first two towns, which is incorrect.

On the other hand, if we use a relative change, sorting by 2A + B, we'll get:

A B
8 1
5 5
2 0

And in this case we'll need to make a speech only in the first town in order to win.

Yes, I had exactly the same logic and I still don't understand why it doesn't work. The only explanation I have — I am too bad at math ... :(

May I please ask somebody to explain why does the 2Ai + Bi works for D, while the Ai + Bi doesn't? Thanks!

Found my mistake, just in case someone is interested, here is my accepted solution.

Hi Guys, could somebody please help me to understand why this simple brute force solution for problem A gets WA on the 4th pretest? Thank you very much in advance!

Thank you for pointing out this interesting idea and algorithm, I will try to get familiar with it and implement.