It's because of Arrays.sort which can run in quadratic time for some inputs.

On EmEnContest Skipped, 7 weeks ago

"Just asking for sake of knowledge."

Ok bro why not post on your main account then?

RIP sleep schedule. Gotta get up at 5am for this contest.

On medudeDo You Use a Debugger?, 2 months ago

Probably because you are too smart and have never made a mistake in your code before.

On medudeDo You Use a Debugger?, 2 months ago

I've never heard of this before, but it sounds interesting. Thanks for your feedback!


Wow, that was quick.

It is quite similar to one of the solutions to the LIS problem.

Edit: problem solution

I disagree. In my opinion, E was not very easy; it is just that there are many very similar problems across the internet, so most people would not be solving it for the first time. For an actual "beginner" who has never seen a similar problem before, I would argue it could be quite challenging. Furthermore, F was not substantially harder than E in my opinion it is just that everyone has seen a similar problem to E before, but not necessarily F. I think the difficulty curve was appropriate for a beginner contest.

I think its your computer; I clicked on his profile and everything was normal.

On medude[Question] Merging Knapsacks, 2 months ago

I see, thanks!

On sraj1614Hopping on the powers of 2, 2 months ago

XOR M and N. The answer is the number of one bits in this value.

On avinash007Help Required, 2 months ago

If you don't understand the editorial, I think that it is a good sign that the problem is too hard and you should return to it later. Solving problems out of your comfort zone is good, but if it is so hard that you can't even understand the solution when given it, then you are probably just wasting your time.

On PetrA 202 week, 2 months ago

Where was that picture taken?

Just my opinion, but most new releases, for any language, have very minimal impact on competitive programming. So it doesn't really matter if it's added to cf or not.

One of my favorite ways to approach any problem I have no clue about is to write a naïve (maybe even exponential) solution. I run this solution on a bunch of small inputs and this way I can see if there are any patterns that might lead to a full solution. I feel like this applies especially well to constructive and greedy problems, but it is also pretty useful for DP as well.


I agree; this format is very fun! This is the first contest I've done where it doesn't put me at a disadvantage to use Java.


Sounds like your problem, not the contest's. I found the questions to be enjoyable and the process went very smoothly. I am quite sure this is the case for many others as well.

Join the club bro. Literally everyone has been downvoted before its not a big deal.


I don't know of any, and there probably aren't any since grading math contests takes far more work than the online judges used in cp. I'm in high school so my main competitions are just AMC, COMC, and some smaller regional ones and all my practice is offline (downloading problemsets and solving them, then comparing with the answers).


If you want to improve your math skills, maybe try some math contests. They can be just as fun and rewarding as competitive programming, and there are tons of good contests and resources which you can access online. Many competitive programmers (including myself) come from a competitive math background before moving on to cp.


On MOOONIJust for fun?, 3 months ago

I am all of the above.

I believe you are referring to this problem:

Normally, I would try something like that, but it seems quite difficult (maybe even impossible) in this case because of two issues:

  1. We are working with circles
  2. We are not working with integer coordinates

That being said, there may be ways to optimize my naive BFS/DFS approach since a lot of the N^2 edges will be redundant.

This is a very interesting problem. I believe I know of a solution, but it depends on how large the constraint for N is. This solution should run O(N^2). First we build a graph on the circles, there is an edge between two circles if they intersect (the distance between their centers is no more than the sum of their radii). Now we perform BFS/DFS on the circles. If we are able to connect the top of the rectangle to the bottom of the rectangle or top to left or left to right or bottom to right, then the answer should be false. Otherwise the answer is true.

While I agree that OOP isn't too relevant to cp, I have seen a lot of cf blogs that are way less useful/productive than this one.

I think I know a decent problem with an editorial (its not on cf though).


Are you sure you have correctly understood and restated the problem statement?

First of all for a case such as: n = 3, a = [1, 2, 1] it seems that there is no solution.

Even assuming -1 (or something similar) is printed in these cases, any solution would still be O(n^2) since this problem is quite similar to bubble sort. This would TLE most of the time for n <= 1e5.

I'm finally able to solve 6 problems in ABC, but now there are 8 total :(

Also, now that ABCs are substantially harder than before, maybe the rated range should also increase?

On medudeString Algos, 4 months ago

Got it, thanks!

On medudeString Algos, 4 months ago

If you don't mind, could you please elaborate on your statement: "if the total length of strings is limited with L, the number of different lengths among strings ≤√2L." I'm not sure what is meant by this.

On medudeString Algos, 4 months ago

This is actually very interesting to me. I wonder why it is that many coders can get very far into their competitive programming journeys and not really use or learn string algorithms. I myself am an example of this, I have been doing cp for over a year now and have not really touched any string algorithms. Its not that string algorithms aren’t useful, I have seen them in plenty of problems and contests, but I just never bothered to learn them for some reason. From what I have observed of other coders, this is true for a decent amount of them as well.

On medudeString Algos, 4 months ago

I see. Thanks again!

On medudeString Algos, 4 months ago

Thank you for the advice! Is there any particular order I should learn these (in terms of importance/usefulness, but also in terms of difficulty/prerequisites)?

Considering that there are thousands of c++ solves I don't think that c++ is the issue...

One way to do this problem would be using coordinate compression + a segment tree. First, compress all of the coordinates to the range [1, n]. Then iterate left to right, while maintaining a minimum segment tree over a function f, where f(x) = min index with value x. At each index i, the answer is i — min(f(1), f(2), ..., f(i)) which can be queried from the segment tree. All f(i) should be initialized to infinite and values should be updated as they come in.

Can some please link the problem (or another problem with same idea)? It sounds interesting so I want to give it a shot.