Comments

Greens don't like this comment

Watch Errichto's stream

Practice regularly by solving problems of slightly higher difficulty than your rating. Learn to analyze time complexity and the big-O notation.

All hail our emperor Anton

+1
+8

I think Problem C will have both an easy and a hard version.

The O(t*sqrt(n)) solution can be optimized to O(sqrt(n) + t*log(n)) if one precalculates all triples and for each test case does binary search

What is pair programming?

On AriCodeforces Global Round 9, 6 years ago
0

Check if the first element is smaller than the last element

I think it's covered in pllk's Competitive Programmer's Handbook

You should initialize count[] with all values equal to 1 instead of 0. j<=sqrt(i) is risky too, sqrt gives float and can create numerical errors. For example, sqrt(25) might give 4.999999997 instead of 5 and you will miss this 5. Better to check j*j<=i

I read in a book "Algorithms" by Dasgupta & Papadimitriou that every DP problem has a directed acyclic graph hidden in it. This is a nice example!

DFS would work, but not with a "visited" array. You DFS from 2 and tick 12 as visited, then you DFS from 3 and miss an edge from 3 to 12.

Also, I think it might get TLE.

+10

You may feel depressed but you learned something. When you come upon this pattern again, you will find it and solve a problem. Good luck in the future!

On BlueSmokeCodeforces Round #641, 6 years ago
0

This is just a waste of time and focus. Good idea not to do it :)

Too much maths, too few algorithms, graphs and data structures. But overall, enjoyable problems.

What is a CN round?

On BlueSmokeCodeforces Round #641, 6 years ago
+6

Eratostene's sieve for the win!

On BlueSmokeCodeforces Round #641, 6 years ago
-9

You can always switch to priority queues ;)

I like problem A. It is easy but interesting and has an educational value.

You can make such testcases: {1 2} {1 2} {3} Whereas my solution would give: {1 1} {2} {2} {3}

It happens...

Thanks! This is what I missed. The greedy solution doesn't work for repeated elements.

You can do it in O(t*(ab+q)) if you precalcutate a prefix array. Such solution of mine took 498ms.

This is one thing and the second is maybe Java is slower than C++.

The first contest you took part in was April's Fools so it was unrated There is a 12 hour hacking phase after the contest so wait and you will get your rating tommorow.

Hi, I tried a greedy solution for D. I sorted an array and added tests from the smallest, for each of them checking how many more I could add to one testcase. It got WA on test 11.

What do you think is the counterexample?

0

Maybe we all can become Gennady ;)

0

Yes, I think the key to improvement is consistency and challenging yourself. I have a habit of solving one 1600-1800 problem everyday and it helps much.

0

Congrats!

+16

I go over each (a_i, a_n-i) pair and find for which sum x I would have to make 0, 1 or 2 replacements. They form ranges so I mark their starts and ends in an array, that lets me solve in linear time.

+7

I am suprised so few people solved it, thought there would be 2-3 times more lucky solvers. I am 1300 elo and I did it! And I was even disappointed it took me so long. Seems my training worked out :D

Instead of hardcoding alphabet to get 'c' letter you can write 'a'+2, to get 'h' write 'a'+7.

Also, managing char* is more difficult than strings. You can make an empty string of length n by typing string s(n) and then you can access elements by s[i].

That is fine. Good luck in problem solving and future contests :)

The code has two nested loops, which makes it O(n^2). In the editorial, you can find a faster O(n) solution.

In general, if you can find something in the editorial, do not waste people's time asking for it on the blog.

How to add the submission link? Go to your profile. Choose the tab "Submissions". Right click on your submission number and copy link. So this is the link: https://mirror.codeforces.com/contest/455/submission/75710100

You may have noticed a few downvotes under the post. Please take care of how you write. OVERUSING BIG LETTERS make you seem SHOUTING. Use commas (,) and dots (.) in a right way so that your post looks tidy and people want to read it.

When will there be rating changes?

Strangely, I started to read coronavirus instead of codeforces :o

Still though, there is no need to remember the whole array of distances between R's. Instead, it is enough to remember the max distance.

How to calculate it without overflowing long long? I can take the modulo when I multiply but it can make the result incorrect when I divide.