Comments
On Irina_Rog → CODEFORCES HAS ROTTEN, 8 years ago
-92

BUMP Codeforces still peace of shit

On msmlkm → 1/2 of New Year magic, 9 years ago
+13

Magic is out of control!

On msmlkm → 1/2 of New Year magic, 9 years ago
+3

bump

If we change

for (int len = 0; len <= max_possible; i++)

in naive O(N^2) solution to

for (int len = ans; len <= max_possible; i++)

it will improove complexity to O(N)

We can use the idea similar to 2 pointers instead of binary search.

  1. Fix the "center" of palindrome
  2. Check all subsrtings that have greater length, that previous answer does.
  3. Update answer if it is possible

It will be O(N)

Hashes + 2 pointers

I do

BTW, nice way to check whether a site is down link

On Kemal → The most beautiful rating graph, 10 years ago
+39
On EvenImage → My sad story, 10 years ago
0

del

In this problem distance is the number of elements that are situated between i and j

So distance between i = 2 and j = 3 is 0

You should find such i, j (i != j) that:

1) a[i] is red

2) a[j] is red

3) distance between i and j is the number that can be divided by K

On ZerocooL95 → Need a graph tool ?, 10 years ago
+23