Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя Timosh

Автор Timosh, 8 часов назад, По-английски

Recently, some people have asked for advice, so I decided to write a blog.

In this blog, I will talk about my approach to problem-solving, what I think about solving problems, how do I learn techniques, data structures and/or algorithms and others.

Solving is guessing

From my interpretation, solving any problem is just some sort of guessing: making an educated guess of the solution, validating, and repeating until solved. You can speed up the "guessing procedure" by simplifiying the problem to a certain degree by, for example, not considering obviously wrong solutions.

Abstraction and Decomposition

Usually, as soon as I finish reading a problem, I try to simplify it as much as possible. For example, sorting arrays, removing elements, handling simple cases, doing greedy decisions whenever can be done, rearranging formulas to more familiar ones, or decomposing the problems into several independent problems. You might even have to solve a harder problem, just because the harder version has a known solution, or you might reformulate the problem into a completely different one.

Visualisation

In my opinion, visualisation is very helpful when thinking about problems or learning new concepts. It makes it a lot easier to understand some seemingly advanced data structures, or to come up with solutions to problems. For example, you can think of arrays as histograms, think of numbers as a product of prime numbers, if it's a problem related to number theory, or as a binary representation, if the problem is about bitmasks, and so on. These interpretations make it easier to think about the problem.

Ego & Motivation

It is very easy to give up competitive programming, as it might seem difficult to improve, or gain rating in codeforces. When I do competitions, olympiads and contests, I usually enter with the "I have to be first" mindset. That usually keeps my brain busy with trying to solve the problems, and sometimes I even end up solving problems which I thought to be impossible at first. But be aware, this could also put you in a stressful situation, e.g. if you get stuck on some problem with "WA on test 2" verdicts, or ending up as the 10,000th place in a contest. Don't take losses like these too personal, look at them as an opportunity to grow (or just being unlucky): "well, seems like there's a case I haven't considered", "hmm, 10k people know how to solve problem X, so it shouldn't be too hard to learn". Encourage yourself that you can be the best.

Some practical advice

  • Don't get stuck thinking about the same idea. Either continue, or change your strategy. Don't be afraid to think about new things.
  • Don't force techniques/topics. "is this dp? is this greedy? is this fft?" is usually not a good strategy if your goal is to improve your pattern recognition or improve in general.
  • If the problem seems too complex, think about a simpler version of the problem, special cases, e.g. $$$n=1$$$, $$$n=2$$$, $$$k=n$$$, $$$a_i \le 2$$$, the graph is a star, or whatever. You will get an outline of the solution for the general problem.
  • Practice. "The simplest solution is usually the right one". Solving lots of problems gives a general understanding on how problems of some kind are solved. It also helps you improve implementation skills, as well as intuition.

P.S. I would like you to share the way you approach problem-solving and/or how you learn new techniques/dsa, so that I get a second opinion. Thanks :P

Полный текст и комментарии »

  • Проголосовать: нравится
  • +49
  • Проголосовать: не нравится

Автор Timosh, история, 8 месяцев назад, По-английски

std::set is a powerful data structure: it allows to do insertions/deletions pretty fast, while also being able to access the smallest/biggest element. On top of that, you can also find the smallest element in the set which is greater than some $$$x$$$. If you can use it properly, it is already enough to solve some of the 1800-2000 rated problems.

On the other hand, what could ordered_set possibly offer? It can do 2 things (other than std::set):

  • st.find_by_order(x) — returns the iterator of the $$$x$$$-th smallest element
  • st.order_of_key(x) — returns the number of elements less than $$$x$$$ (i.e. index of the smallest element $$$\ge x$$$)

One of the basic applications of ordered_set would be counting the number of inversions of an arbitrary permutation.

For comparison:

Ordered set way

ordered_set<int> st;
int ans = 0;
for (int i = n - 1; i >= 0; i--)
   ans += st.order_of_key(p[i]), st.insert(p[i]);

Merge sort way

// too long to fit in 65536 characters

"There's not much you can do with this, other than count inversions", you might foolishly say, without having solved 2400-2500 rated problems using just ordered_set. Let's take 2064E - Mycraft Sand Sort as an example. In the editorial it says "blah blah blah, use dsu and segtree". But little does the foolish author of this problem know, is the existence of ordered_set (Intellegent is actually noob). As you can see in 306417199, it can easily be solved using 2 ordered_sets. Why use 2 different data structures when you can use a single one twice? Another example would be 2059E1 - Stop Gaming (Easy Version), which is also intended to have a long-implemented solution, yet still solvable using just the ordered_set, which will end up being a lot shorter than the intended code. There are a lot more problems than these which could be solved using ordered_set, it's just that I couldn't find worthy candidates for this blog(maybe you can help).

Another funny (but not really useful) application, is handling point update and range sum queries in $$$O(log\ n\ log\ A)$$$(where $$$A$$$ is the max element). It can be done by creating $$$log\ A$$$ ordered sets, and inserting each bit of the element being added to the corresponding ordered set. To get a sum in $$$[l, r]$$$, we can just count the number of elements between $$$l$$$ and $$$r$$$ for each bit, and sum everything up.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +51
  • Проголосовать: не нравится

Автор Timosh, история, 11 месяцев назад, По-английски

At the end of today's contest after solving A-E, I was like "yay, finally, 2200+". But as system testing ended, my submission for D got FSTed (I still don't know why). Moreover, It seems like it's the only FST for problem D in the entire contest, which makes it even more disappointing. I don't know how to feel about this, maybe I invented new ways to fail system testing?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +35
  • Проголосовать: не нравится

Автор Timosh, 17 месяцев назад, По-английски

Hello everyone!

In this blog, I’d like to share my journey into Competitive Programming (CP), along with some tips and insights.

Math to CP

Before I got into CP, I was a math Olympiad enthusiast. I participated in competitions like AMC, SEAMO, IMC, and others, achieving pretty good results—even without significant training. I think my logical thinking helped a lot.

However, I never made it to the IMO. In 9th grade, during my last math Olympiad, I had a disappointing result—I scored 0/50 on the written portion, where you had to prove your solutions. Around that time, I already knew about Codeforces, but the problems seemed too difficult, and I felt it wasn’t for me that time.

That’s when I decided to give Competitive Programming a serious try.

Transitioning to CP wasn’t that hard, since I already had some experience with basic C++. A friend of mine, C0deN1nja, helped me get familiar with the platform and how the system worked.

Unexpected Growth

At first, I thought I would converge somewhere in the middle of the Expert rank. Improving seemed tough, and I didn’t think I had what it took to progress much further. But to my surprise, I reached Expert in just two months—and then I began aiming for Candidate Master.

At the time, I couldn’t imagine becoming a Master anytime soon. It felt like a whole new level, and I thought I’d first need to become a consistent CM.

Then came Educational Codeforces Round 174 (Rated for Div. 2). I was solving problems as usual, until I reached Problem E. As I read through it, I instantly recognized it was very similar to 1686D - Linguistics. The only twist was converting “exactly” to “at most” using some mathy techniques.

Thanks to that familiarity, I got a bit lucky and performed well in that contest. I knew I’d likely drop in the following rounds, but it didn’t take long before I bounced back and regained Master.

I placed 22nd in Codeforces Round 1011 (Div. 2), and came close to reaching International Master in Codeforces Round 1012 (Div. 1)—if only it hadn’t been for Problem C1. (Who knows, maybe IM is not that far either?)

Tips(?)

I’m not the best to give advices—everyone has their own training methods. But I can give a couple tips which could be helpful to you:

  • Don't practice topic-wise (unless you need to), if you want to improve your pattern recognition and avoid "idea forcing".

  • Try many different ideas on a problem if stuck, this will be helpful to improve your intuition and it will be a huge experience boost. (I believe)

I was never afraid of learning new things, I think that's why I could reach Master so easily.

If you have any questions, feel free to ask them in the comments!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +61
  • Проголосовать: не нравится

Автор Timosh, история, 19 месяцев назад, По-английски

I managed to solve 2 problems on Codeforces Round 1004 (Div. 1), which may not be much, but it was quite frustrating to see that I was ranked 800/1080, while I was used to seeing something like 300/27K on Div. 2s. Is it even worth taking part on Div. 1s as a CM?

Полный текст и комментарии »

  • Проголосовать: нравится
  • -23
  • Проголосовать: не нравится

Автор Timosh, 20 месяцев назад, По-английски

Hello, everyone!

I’d like to share a problem I came up with, which I believe to be quite unique (as I haven’t come across anything similar elsewhere).

I’ve created many problems for various platforms, but Timosh and Number Theory is the one I consider the most original. I hope you find it intriguing!

The problem is quite challenging — only 5 participants managed to solve it under contest conditions. If you’re looking for an even tougher challenge, there’s a harder version available: Timosh and Number Theory #2.

I’d love to hear your thoughts on this problem!

UPD:

Solution(Easy version)
Author's code
Shorter solution by one of the solvers

Полный текст и комментарии »

  • Проголосовать: нравится
  • +26
  • Проголосовать: не нравится

Автор Timosh, история, 23 месяца назад, По-английски
  • Проголосовать: нравится
  • +69
  • Проголосовать: не нравится

Автор Timosh, 2 года назад, По-английски

In the recent National Olympiad in Informatics in our country, there was a problem, that many struggled to solve, it was worth 16 points, for being "the hardest problem". I got a great result then, for solving it fast. However, I forgot the actual solution. Anyways, here is the problem statement, ignoring the stories and drama:

You are given 3 integers, $$$a$$$, $$$b$$$ and $$$n$$$. Your task is to find any integers $$$x$$$ ($$$x \ge a$$$) and $$$y$$$ ($$$y \ge b$$$), such that $$$xy \ge n$$$, and $$$xy-n$$$ is minimised

I remember using a $$$O(\sqrt{n})$$$ solution, but not what it actually was. Anyone has ideas?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор Timosh, история, 2 года назад, По-английски

I always wanted to help organize a contest, however I see almost every problemsetter is atleast a master. On top of that, I tried to create a problem statement in polygon, it was sophisticated, all those validators, chekers, thing called testlib.h. So, I want to atleast be a tester of a contest. Who can tell how to be one?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

Автор Timosh, история, 2 года назад, По-английски

Hello Codeforces. Recently I faced a problem which I couldn't solve in an hour. It is as follows: Max Sum Subarray of atleast 2 numbers. Of course, for just max sum subarray it is Kadane's algorithm in O(n) time, however, I couldn't think of a way to solve for atleast 2 numbers faster than O(n^2). Any idea or a solution?

UPD: Thanks everyone. Now I know how to solve this problem

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Timosh, история, 2 года назад, По-английски

Hello Codeforces!

This is my first ever blog entry. My name is Timur, 15 y.o., from Uzbekistan. I joined Competitive Programming recently(even though in Codeforces for 4 years). From a young age i thought coding was fun, so I found out about competitive programming, and started out with Robocontest(uz). Solving problems was like a logic and an intuitive puzzle, if it's easy, you find solution immediately after reading the problem, if it's medium, you think a little bit and still find a solution(maybe not), but if it's hard, then you don't even try to do it. Same with Codeforces, never did a F|1800 task. It's crazy that some people can solve them in 5 minutes O-O. And all those data types, structures, algorithms. brrr. Anyways, I hope to get help and support from the community, and maybe meet some friends. :D

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится