Dominater069's blog

By Dominater069, 2 days ago, In English

Recently, I got a request asking me to write down my thought process while solving questions. So, here is the promised blog.

I would like to thank IceKnight1093, qwexd, Sana, Everule and NovusStellachan for proof reading and suggesting edits in the blog. Special thanks to satyam343 for discussing most of the blog with me.

1. Overview

The blog contains my solutions to $$$7$$$ problems in a wide range of ratings, starting from $$$1200$$$ all the way upto $$$2700$$$. Each problem has a step-by-step solution and you can notice how there are no large jumps in logic, but everything comes naturally. I do not claim that this is always possible in each problem, however I solve majority of CF problems in such a manner.

There are certainly other high rated people who will have completely different methods of solving. However, this is about what works for me. There are some meta ideas taken from parts of the solution and listed at the end in a "What can we learn?" section. I hope the blog is useful for you.

2. Some General Question Solving Strategies

Here is a non-exhaustive list of techniques that are useful to keep in mind. These are internalized by most experienced participants already but maybe it helps you.

  • Figuring out the Nature of an Optimal Solution. One of the most important thing in problems imo.

  • Solving subtasks of the original problem and then trying to extend/generalize your solution.

  • Fixing a parameter and then trying to maximise the result with respect to that fixed parameter.

  • Finding necessary and sufficient conditions. Sometimes, your necessary conditions themselves become sufficient, or vice versa.

  • Identifying Lower and Upper bounds, and constructing them.

  • Reducing a problem into smaller subproblems, commonly used with Dynamic Programming or Inductive Proofs.

  • Considering the Decision Version of the Problem instead. Especially useful in Counting problems, where you need to count number of good subsequences for example.

  • Formalizing the Problem

3. Questions and Solutions Section

Question 1. 1979C - Earning on Bets

Step 1
Step 2
What can we learn?

Question 2. 1987D - World is Mine

General Idea
Step 1
Step 2
Step 3
Step 4
What can we learn?
Similiar Problems

Question 3. 1977C - Nikita and LCM

Step 1
Step 2
What can we learn?

Question 4. 1889B - Doremy's Connecting Plan

Step 1
Step 2
Step 3
What can we learn?

Question 5. 2002D1 - DFS Checker (Easy Version)

Step 1
Step 2
Additional Note
Implementation
What can we learn?

Question 6. 1930E - 2..3...4.... Wonderful! Wonderful!

Step 1
Step 2
Step 3
What can we learn?

Question 7. 2003E1 - Turtle and Inversions (Easy Version)

Disclaimer : My solution differs from the editorial completely. You can read the editorial for their approach. I will present mine. Try to extend to the hard version of the problem from this.

Subproblem
Subproblem Step 1
Subproblem Step 2
Subproblem Step 3
Step 4
Additional Note
Hint 1 of Hard Version
Hint 2 of Hard Version
What can we learn?

4. About Stress Testing

Something which a lot of low rated participants do wrong : They don't stress test.

There have even been contests where I stress tested $$$3$$$ problems. I tend to make a lot of errors while writing code and it is not easy to always catch those errors with manually reading or debugging. Learning the skill of stress testing is insanely useful (and you don't need any tools for it, I do it all in the same piece of code without taking much time).

This was the first problem (I think) that i had stress tested during contest : 1854A1 - Dual (Easy Version) I was still done within $$$12$$$ minutes and it took me less than $$$5$$$ mins to stress test, and fix my bug (this is an easy example though as I didn't have to write a brute). My bug only occurred when all elements of the array were equal and negative, I don't think I would manually be able to catch that.

1987F1 - Interesting Problem (Easy Version) In the initial submission to this problem, I missed so many if-cases. I was very careless. But i managed to stress test and avoid more WAs. I think it took me 3 — 4 iterations of finding bug with stress test, fixing them and then again running stress test before my code was actually correct.

I highly recommend stress testing for you. It is simpler than you think : all you need is a brute function, and a generator. I usually replace my input function with a generator, and use a lambda function for the brute. It takes barely $$$5$$$ minutes to setup for most problems.

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

»
5 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Dominater069 orz Thanks for the CodeChef rounds and for writing comments in your solutions. I hope to see more educational blogs and contests from you.

»
5 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

bro stop wasting your times writing this blogs and instead practice some problems.
we are desperately waiting for first LGM from bharat

»
5 hours ago, # |
  Vote: I like it +16 Vote: I do not like it

Thanks for the blog. Also congrats Dominater069 on reaching 2800+ and LGM performance this contest.

»
5 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

thanks

»
5 hours ago, # |
  Vote: I like it +5 Vote: I do not like it

Thanks for the great blog! I think it's worth mention that writing a few example on paper and making conjecture/observation based on them is also extremely useful and used a lot when solving ad-hoc problems.

»
5 hours ago, # |
  Vote: I like it +28 Vote: I do not like it

I guess Radewoosh was incorrect on this one /j

Also, one last tip: I've noticed it observing all the top people on Codeforces/Atcoder. None of them uses the word "question" instead of "problem"/"task". So don't do it. You won't progress if you'll keep calling problems "questions"
  • »
    »
    3 hours ago, # ^ |
      Vote: I like it +37 Vote: I do not like it

    It is intentionally done due to that :)

    If you look deeper into the blog, i always mention "problems" (because i was lazy to change them) only the headings have questions

»
4 hours ago, # |
  Vote: I like it +46 Vote: I do not like it

God, it's like staring in the mirror...