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

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

I created video editorial for D. Iris and Game on the Tree from last Codeforces Round.

https://youtu.be/xDYXvn0NfA0?si=pe3Tzwb3z-CDWZoA

I also created a practice contest containing 3 Game Theory Problems (that I will keep updating in future). https://mirror.codeforces.com/group/7Dn3ObOpau/contest/546860

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

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

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

I created video editorial for D. Longest Max Min Subsequence from last Div 2 round, that discusses multiple approaches for this problem, involving data structures like set, map, vector, dequeue, segment tree, stack, and algorithms such as Binary Search, Greedy Algorithms, Next Greater Element, Exchange Argument.

Problems discussed :

  1. Check if pattern exists as subsequence in text.
  2. Finding lexicographically smallest subsequence with maximal length containing only unique elements.
  3. CF2001D: Longest Max Min Subsequence

https://youtu.be/fiiGEH0nb-w?si=j_Q-Z8KGJgKMfrrh

I also created a practice contest that contains all problems mentioned in the video. Here is the link to the contest https://mirror.codeforces.com/group/7Dn3ObOpau/contest/545195

The problems are untested, if you see any issues, do let me know.

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

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

Автор adaptatron, 3 недели назад, По-английски

Problem E. Cosmic Rays from last Div1 + Div2 Round had an interesting application of stack. So, I created a video editorial to help you visualize stack problems using graph modelling.

https://youtu.be/l2LTxerp2KE?si=FQzjaNj1Y-QiMH1V

I also created a practice contest https://mirror.codeforces.com/group/7Dn3ObOpau/contest/542909

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

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

Автор adaptatron, 3 недели назад, По-английски

The last problem from today's Codechef starter dealt with diameter of weighted trees. So I created a video discussing the general ideas behind computing diameter of weighted/unweighted tree, and the farthest node from each node (using ideas from this amazing blog by TheScrasse )

https://youtu.be/UhhIFuHhllE?si=mpzEwZwm9py7OgFT

3 Practice Problems :

  1. CSES : Tree Diameter
  2. CSES : Tree Distances 1
  3. Codeforces : Three Paths on a Tree

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

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

Автор adaptatron, 5 недель назад, По-английски

I created a video discussing how to compute the XOR of all numbers in the range $$$[L, R]$$$ in $$$O(1)$$$. It also talks about how to compute the number of set bits at position $$$p$$$ in the range $$$[L, R]$$$ (people usually get confused with off-by-one errors in these problems, Not anymore!).

Although not directly related, XORs and modulo 4 appeared in the last Codeforces Round. This trick is not known by many, so I decided to create a video.

https://youtu.be/v8G2gjQ_gp8?si=rG60v07Bn4mTL-dw

If you want to apply this info to an actual problem, here's a practice contest https://mirror.codeforces.com/group/7Dn3ObOpau/contest/539212

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

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

Автор adaptatron, 5 недель назад, По-английски

I created a video discussing strategies to upsolve and read editorials for Codeforces problems. It also talks about how to use Atcoder Library like STL, in context of problem G: Penacony from last Div 3 Round.

https://youtu.be/iMjd2QI6NEs?si=Xr9g2Mz_HTwLBLQ8

I also curated some practice problems. Here's the contest link : https://mirror.codeforces.com/group/7Dn3ObOpau/contest/538988

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

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

Автор adaptatron, 5 недель назад, По-английски

I created a video editorial for Problem D : Cases from last Codeforces Round 961 (Div 2)

https://youtu.be/LgxHoy3Aguk?si=XcacblYTS5nIHMf0

I also created a practice contest with easy version of the problem. You can find it here https://mirror.codeforces.com/group/7Dn3ObOpau/contest/538630

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

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

Автор adaptatron, 6 недель назад, По-английски

I created a video that talks about how to efficiently and easily compute the next smaller element, second next smaller element and so on, using a set instead of stack. It also talks about a non trivial contribution technique that recently appeared as part of problem E: Range Minimum Sum from Codeforces Round 958.

Here is the video link https://youtu.be/MRlaULKT9V4?si=PfpyqPIJns0OMRqb

I also curated some practice problems and created easy version of problem E. You can find the contest here https://mirror.codeforces.com/group/7Dn3ObOpau/contest/537569

The problems are untested, if you see any issues, do let me know.

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

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

Автор adaptatron, 6 недель назад, По-английски

I made a video editorial discussing the intuition behind problem D: The Omnipotent Monster Killer from last Codeforces Round 958. It also talks about a neat trick to analyze the time complexity of Tree DP problems. I also created a practice contest for you to assess your cubic and quadratic solutions.

https://youtu.be/exUm24JN2-A?si=uQsyu0tz571kwinW

Here is the link to the contest https://mirror.codeforces.com/group/7Dn3ObOpau/contest/536755

Here are the slides, blog, code, similar problems and other resources used in the video https://cfstep.com/codeforces/contests/contest-1988/problem-d/

If you need any help, or if you notice anything wrong with the easy version of the problems, do let me know in the comment section.

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

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

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

TL;DR : I created a practice contest that contains 6 problems that use the same underlying DP idea.

https://mirror.codeforces.com/group/7Dn3ObOpau/contest/532384

I will publish the blog soon. Till then, feel free to discuss your approach in the comment section.

DP on distinct subsequences is one of the easiest DP to implement, but also the hardest DP to come up with. It is like an optical illusion, where at the start, you’d think that it’s impossible for such a simple code to work, but once you finally understand how the algorithm works, you’d think that the problem was a cakewalk.

To truly appreciate the beauty of the solution, it’s important that, before reading the blog, you spend a significant amount of time attempting all the 7 problems that I’ve created.

P.S : The problems are untested, if you see any issues, do let me know.

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

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

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

The last Educational round contained an interesting problem D on Balanced parenthesis, which becomes almost trivial if someone has read this 8 year old comment by tenshi_kanade that talks about a much easier problem

Count the number of substrings that are balanced parenthesis.

I created a blog that talks about this idea in a bit more detail and also discusses how to modify the solution of this problem to make it work for the Edu problem. I also created practice problems on it so that you can submit your $$$O(n^2)$$$ and $$$O(n)$$$ approach. This is the contest link https://mirror.codeforces.com/group/7Dn3ObOpau/contest/527306

https://cfstep.com/training/tutorials/general-techniques/balanced-parenthesis-on-segments/

The problems are untested. If you see any issues, please let me know.

If you need any help or hints for the practice problem, you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

I created a blog that talks about 3 quirks of maps/multisets.

  1. Accessing non existent elements in maps keyed on characters may lead to WA.
  2. Accessing non existent elements in maps keyed on integers may lead to TLE.
  3. Using the fancy count operator in multisets may lead to TLE.

There's no new/unique insights, I just documented my personal experience with these quirks, along with the problems link where I first encountered this issue. It might be helpful to beginners in competitive programming.

https://cfstep.com/training/tutorials/general-techniques/quirks-of-non-existent-map-elements/

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

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

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

The editorial of D. Colored Balls mentions that the first part of the problem is a standard puzzle, so it doesn't go into too much details. However, what's standard to old timers is new learning opportunities for newcomers. At least, to me, it was not at all obvious why the given formula works, until I encountered a good visual proof for the same.

I created a video talking about the strategy to solve the puzzle, with proof.

https://youtu.be/3TbkZ1A489o?si=V6Qq5CoXdbAfPi6U

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

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

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

Problem Link

Target Audience : If you are not able to come up with the $$$O(n^2)$$$ algorithm in 5 minutes, and the $$$O(n)$$$ algorithm in additional 5 minutes, this tutorial is for you. If you are a beginner to Dynamic Programming on Prefix, this 1D DP problem is a good starting point for you to learn the technique. This tutorial assumes that you already have some experience with 1D DP.

I came across a simple yet elegant problem, which might be trivial to some but a good learning experience for others. So I created a blog that talks about how to optimize DP transitions by switching from Pull DP to Push DP.

You can submit your $$$O(n^2)$$$ and $$$O(n)$$$ solution here : https://mirror.codeforces.com/group/7Dn3ObOpau/contest/517981

https://cfstep.com/training/tutorials/dp/push-dp-vs-pull-dp/

If you have an alternate solution for any of these problems, do let me know in the comments.

If you have more practice problems on this concept, please share them in the comments below and I'll add them to the practice contest.

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

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

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

I created video editorial for H. The Most Reckless Defense from last Div 3 Round (CF Round 938). It talks about Bitmask DP, exponentials, and how to approach problems with long description.

Youtube Link : https://youtu.be/bBTW58NEoJ4?si=zItmAtlyEGBiNMG_

Here's a practice contest on bitmask and bitmask DP

If you need any help or hints for the practice problem, you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

To improve, just upsolving problems is not enough. You also need to ask yourself at what point you diverged from the intended solution, or what you could've done differently to arrive at the intended solution.

I made a video editorial discussing my train of thoughts involved for solving D. Learning to Paint from last CodeTON Round. The video talks about how you can spot patterns in problems and use them to your advantage for future problems.

Youtube Link : https://youtu.be/EGp72-5MV8U?si=1l9kq1SFQ_qhFRro

If you need any help (for this problem only), you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

I made a video editorial discussing D. Birthday Gift from last Div 2 Round (CF Round 936). The video talks about how the concept of submasks can be helpful outside of subset counting problems.

Youtube Link : https://youtu.be/qZobx4EOVm0?si=LsPPCv4mi2szw-PR

Here's a practice contest on bitwise operations:

If you need any help or hints for the practice problem, you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

Given an array of positive integers, for each element, you can choose to multiply it by $$$-1$$$. Find the maximum number of negative elements at the end, such that the prefix sum of the final array contains strictly positive integers only.

I created a short blog that talks about how the obviously incorrect greedy strategy for some problems can actually be fine-tuned to be correct, by going back and altering our choices.

To help you solidify the concepts discussed, I've created 1 + 1 practice problems. You can access them here: https://mirror.codeforces.com/group/7Dn3ObOpau/contest/513385

https://cfstep.com/training/tutorials/general-techniques/time-travel-in-greedy-algorithms/

If you have an alternate solution for any of these problems, do let me know in the comments.

If you have more practice problems on this concept, please share them in the comments below and I'll add them to the practice contest.

The problems are untested. If you see any issues, please let me know.

If you need any help or hints for the practice problem, you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

I made a video editorial for CF1923E : Count Paths discussing the DP solution that acts as the foundation of the small to large trick.

Youtube Link : https://youtu.be/D454rHDUb6E?si=FtfBwoKG3_p-8m7f

I also created practice contest with easy problems:

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

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

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

I made a video editorial discussing G. Vlad and Trouble at MIT from last Div 4 Round (CF Round 928). The video can act as a gentle introduction to Tree DP.

Youtube Link : https://youtu.be/xB2sZz7aa-M?si=z2eRU0dDai-jodmf

Here are 3 practice contests:

If you're a complete beginner, then you should only attempt these 3 problems : 1, 2 and 3

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

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

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

The editorial for ABC340G: Leaf Color from last Atcoder Beginner Contest mentions an interesting exercise/subproblem for the readers

Fix a color and find the answer in $$$O(N)$$$ with Tree DP. Although not easy, it is a good exercise for blue coders, so we recommend you to think about it.

So I created a blog post that discusses how to find

  1. The number of induced subgraphs that are trees.
  2. Number of connected induced subgraphs with degree $$$d$$$ for any $$$d$$$.
  3. Number of connected induced subgraphs with degrees $$$0$$$, $$$1$$$ and $$$\geq 2$$$.
  4. Number of connected induced subgraphs with monochromatic degree 1 vertices.
  5. Followup problem to apply the concepts learned.

To help you solidify the concepts discussed, I've created 2 + 1 practice problems. You can access them here: https://mirror.codeforces.com/group/7Dn3ObOpau/contest/504547

https://cfstep.com/training/tutorials/trees/dp-on-induced-subgraphs-of-a-tree/

If you have an alternate solution for any of these problems, do let me know in the comments.

The problems are untested. If you see any issues, please let me know.

If you need any help or hints for the practice problem, you can ask on my Discord Server or on the Twitter thread. In case you are interested, you can also checkout my youtube channel

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

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

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

ABC339G: Smaller Sum from the last week's ABC had restrictions for online query and someone in the comment section was interested in knowing the alternate easier solution if the queries could be answered offline. So, I've written a short blog that talks about how to use sweep line to answer these 2 problems:

  1. You are given an array and several queries. A query consists of a subarray and $$$x$$$. Print the sum of all elements from this subarray that are $$$\leq x$$$.
  2. You are given a tree and some queries. In each query $$$(x, y, T)$$$ print YES if there is a path from $$$x$$$ to $$$y$$$ such that the maximum value on that path is $$$ \leq T$$$.

To help you solidify the concepts discussed, I've created 1 + 1 practice problems. You can access them https://mirror.codeforces.com/group/7Dn3ObOpau/contest/503852

https://cfstep.com/training/tutorials/general-techniques/answering-queries-offline-with-sweepline/

The problems are untested. If you see any issues, please let me know.

If you need any help or hints for the practice problem, you can ask on my Discord Server. In case you are interested, you can also checkout my youtube channel

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

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

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

Given an array, how do you efficiently find out the minimum xor pair. I've written a short blog discussing the idea behind it.

To help you solidify the concepts discussed, I've created 1 + 1 practice problems. You can access them here: https://mirror.codeforces.com/group/7Dn3ObOpau/contest/503551

https://cfstep.com/training/tutorials/bitwise-operations/xor-is-minimized-for-adjacent-sorted-elements/

The problems are untested. If you see any issues, please let me know.

If you need any help or hints for the practice problem, you can ask on my Discord Server. In case you are interested, you can also checkout my youtube channel

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

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

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

The editorial of ARC171C mentions that the sum of $$$\prod deg(u)!$$$ over all spanning subgraphs can be computed using DP but doesn't mention how. So I created a blog post that discusses how to compute:

  1. Number of spanning subgraphs where root vertex has degree $$$d$$$.
  2. Sum of $$$\prod deg(u)!$$$ over all spanning subgraphs
  3. Sum of $$$\sum deg(u)$$$ over all spanning subgraphs

To help you solidify the concepts discussed, I've created 2 + 1 practice problems. You can access them here: https://mirror.codeforces.com/group/7Dn3ObOpau/contest/503270

https://cfstep.com/training/tutorials/trees/dp-on-spanning-subgraphs-of-a-tree/

The problems are untested. If you see any issues, please let me know.

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

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

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

I've written a short blog discussing the idea of extending Binary Strings with DP. It also discusses the solution to problem E: Counting Binary Strings from last Div 2 round.

To help you solidify the concepts discussed, I've created 5 + 1 practice problems. You can access them here: https://mirror.codeforces.com/group/7Dn3ObOpau/contest/498710

https://cfstep.com/training/tutorials/strings/extending-binary-strings/

The problems are untested. If you see any issues, please let me know.

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

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