Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Timosh's blog

By Timosh, 7 hours ago, In English

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

  • Vote: I like it
  • +46
  • Vote: I do not like it

»
7 hours ago, hide # |
Rev. 2  
Vote: I like it +7 Vote: I do not like it

A really huge tip that helped me reach finals of national OI is to simply use pen and paper. While it sounds insignificant, holding several (sometimes up to 15) invariants/concepts/variables/definitions/... in your head makes it practically impossible to solve a problem. Pen and paper (Even better, an infinite canvas such as microsoft onenote) make you able to look at either structural or answer patterns. You will see immense improvements in using a canvas.

Another tip is to get the f**k out of your comfort zone. If you're good at greedy but bad at DP, practice DP to the point that it becomes automatic. This does not mean do not practice things you're good at.

Last but not least, one of my international olympiad medalist friends said this "It's never going to look good, and if it does, it's likely[actually] not. All you can do to improve is solve, solve, and solve."

  • »
    »
    37 minutes ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I would like to add I can't hold 5 single-letter variables in my brain, that's why I make longer variable names.

»
91 minute(s) ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

is this fft?

The most human question I've ever heard for a long time

»
82 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thanks for the advice and idea. I am just curious to know did you have any sort of olympiad background or similar things Can we also add training math and other similar things, like USAMO, targeted problem solving practice to improve the raw thing ? so that the main part of breaking things down get's a bit easier

  • »
    »
    58 minutes ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

    Well, yeah. Previously I did math olympiads and competitions, including AMC, SEAMO and IMC. I can't say I was very great at math, but yeah, I'd say my olympiad backround helped me with the "breaking things down" when it comes to cp problems. I don't think you have to be solving math problems tho, codeforces problems are just as good, but doesn't hurt to try.