Shayan's blog

By Shayan, 4 days ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2037A — Twice

Video

2037B — Intercepted Inputs

Video

2037C — Superultra's Favorite Permutation

Video

2037D — Sharky Surfing

Video

2037E — Kachina's Favorite Binary String

Video

2037F — Ardent Flames

Video

2037G — Natlan Exploring

Video

Full text and comments »

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

By Shayan, 11 days ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2028A — Alice's Adventures in "Chess"

Video

2028B — Alice's Adventures in Permuting

Video

2028C — Alice's Adventures in Cutting Cake

Video

2028D — Alice's Adventures in Cards

Video

2028E — Alice's Adventures in the Rabbit Hole

Video

2028F — Alice's Adventures in Addition

Video

Full text and comments »

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

By Shayan, history, 12 days ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2029A — Set

Video

2029B — Replacement

Video

2029C — New Rating

Video

2029D — Cool Graph

Video

Full text and comments »

  • Vote: I like it
  • -34
  • Vote: I do not like it

By Shayan, 3 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2036A — Quintomania

Video

2036B — Startup

Video

2036C — Anya and 1100

Video

2036D — I Love 1543

Video

2036E — Reverse the Rivers

Video

2036F — XORificator 3000

Video

2036G — Library of Magic

Video

Full text and comments »

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

By Shayan, history, 3 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2032A — Circuit

Video

2032B — Medians

Video

2032C — Trinity

Video

2032D — Genokraken

Video

2032E — Balanced

Video

Full text and comments »

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

By Shayan, history, 3 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2026A — Perpendicular Segments

Video

2026B — Black Cells

Video

2026C — Action Figures

Video

2026D — Sums of Segments

Video

2026E — Best Subsequence

Video

Full text and comments »

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

By Shayan, 4 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2035A — Sliding

Video

2035B — Everyone Loves Tres

Video

2035C — Alya and Permutation

Video

2035D — Yet Another Real Number Problem

Video

2035E — Monster (Observations)

Video

Full text and comments »

  • Vote: I like it
  • -43
  • Vote: I do not like it

By Shayan, 4 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2027A — Rectangle Arrangement

Video

2027B — Stalin Sort

Video

2027C — Add Zeros

Video

2027D2 — The Endspeaker (Hard Version)

Video

Full text and comments »

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

By Shayan, 4 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2033A — Sakurako and Kosuke

Video

2033B — Sakurako and Water

Video

2033C — Sakurako's Field Trip

Video

2033D — Kousuke's Assignment

Video

2033E — Sakurako, Kosuke, and the Permutation

Video

2033F — Kosuke's Sloth

Video

Full text and comments »

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

By Shayan, 5 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2030A — A Gift From Orangutan

Video

2030B — Minimise Oneness

Video

2030C — A TRUE Battle

Video

2030D — QED's Favorite Permutation

Video

2030E — MEXimize the Score

Video

Full text and comments »

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

By Shayan, 6 weeks ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2022A — Bus to Pénjamo

Video

2022B — Kar Salesman

Video

2022C — Gerrymandering

Video

2022D1 — Asesino (Easy Version)

Video

2022E1 — Billetes MX (Easy Version)

Video

2022E2 — Billetes MX (Hard Version)

Video

Full text and comments »

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

By Shayan, 7 weeks ago, In English

Hi,

Our last topic stream was on Number Theory. I will continue discussing number theory next week, where we will cover more facts and solve more problems.

Here is the text version of this topic stream. I will briefly summarize all the topics discussed in the livestream. You can watch the full session below.

Full Video of the Number Theory Session

Definition of GCD

In this section, I introduce the concept of the Greatest Common Divisor.

Video

Proving that gcd(a, b) = gcd(a — b, b)

As the title suggests, we prove a fact about GCD. This fact is extremely useful!

Video

The Naive Algorithm to Calculate GCD

Here, we introduce the naive solution to calculate the GCD. It works in O(min(a, b)) by simply iterating through all possible candidates.

Video

Extend the Fact to gcd(a, b) = gcd(a % b, b)

Then, we extend the fact that gcd(a, b) = gcd(a — b, b) to gcd(a, b) = gcd(a % b, b).

Video

Prove that a % b < a / 2 if a >= b

In this section, we prove another very useful fact, which helps us find the GCD with improved time complexity.

Video

O(lg a) Algorithm to Calculate GCD

Here, we use the facts to improve our solution to calculate the gcd of two numbers.

Video

Solving 1458A from Codeforces

In this section, the following problem will be solved. It is really beautiful.

https://codeforces.net/problemset/problem/1458/A

Video

How to Find All the Prime Numbers between 1 and N in O(N)

Another classic problem in number theory.

Video

Improving the Algorithm to O(N sqrt(N))

We use a simple fact to reduce one N to sqrt(N).

Video

Sieve of Eratosthenes — Improving the Algorithm to O(N.lgN)

Here, I introduce the Sieve of Eratosthenes. I explain the solution step by step, and at the end, I mention that this method is called the Sieve of Eratosthenes.

Video

Harmonic Series

In the middle of solving the problem with this method, we encounter with a number that we have to find out how big it is. We need this to find out the time complexity of our method. We will analyze the complexity of this number. We will analyze the complexity of this number, and we’ll see that it is actually known as the Harmonic Series.

Video

Solving 230B from Codeforces

Then, we try to use the topics we talked about to solve the following problem from Codeforces.

https://codeforces.net/problemset/problem/230/B

Video

Find the Smallest Prime Factor with Sieve

Actually, Sieve can be used to solve more challenging problems as well. Here, we discuss how to find the smallest prime factor of a number using Sieve.

Video

Full text and comments »

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

By Shayan, 2 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2020A — Find Minimum Operations

Video

2020B — Brightness Begins

Video

2020C — Bitwise Balancing

Video

2020D — Connect the Dots

Video

2020E — Expected Power

Video

Full text and comments »

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

By Shayan, 2 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2019A — Max Plus Size

Video

2019B — All Pairs Segments

Video

2019C — Cards Partition

Video

2019D — Speedbreaker

Video

2019E — Tree Pruning

Video

Full text and comments »

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

By Shayan, 2 months ago, In English

ICPC World Finals 2024 is happening right now, and I’m planning to upload a vlog every day. The internet speed here is a bit questionable, so it might take some time for the videos to go up.

By the way, the first video (day 0 and 1) is already uploaded, and day 2 will be up soon. You can also check out the pictures below!

This blog will be updated.

Day 0 & Day 1 Vlog

Full text and comments »

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

By Shayan, 2 months ago, In English

Hello Codeforces,

ICPC WF 2024 is happening next week, and we’re heading to Kazakhstan on Friday night.

As I’ve done plenty of interviews and AMAs, but I’ve never been the one answering questions, and as tomorrow will be our final training session, we’re planning to have an AUA afterward.

Sam (sam571128), Colin (galen_colin), and I (Shayan) will be there to talk about our goals for ICPC, how we’ve been preparing lately, and answer your questions. It’s going to be fun!

Here is the link: https://www.youtube.com/watch?v=UD4plaiJ4bc

(Since it’ll be late night in the US and not an appropriate time pretty much anywhere in the world, it will be recorded as well.)

Btw, the most important question of this blog post is, what’s your favorite team in ICPC this year? (UMD White, right?)

Full text and comments »

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

By Shayan, 2 months ago, In English

Hello Codeforces,

It’s been a long time since we announced my interview with Reyna.

One question that always comes up is: what comes after learning and excelling in competitive programming? Is it really possible to land a well-paid job after reaching a high level in CP? In this interview, Arash tries to answer this question.

Arash owns a Gold and a Silver medal in IOI. He has also participated in a lot of onsite competitions. In this interview, he talks about his thoughts on competitive programming, his journey, and how he learned competitive programming.

Right now, Arash works as a quantitative researcher and earns more than $500,000 per year. He believes that this field is one of the most suitable fields for top competitive programmers, and having a great CP background helps a lot to land a job in the field. He talks about his job, how he got into the field, how others might land a job in this field, and how well-paid this field is. He also shares his recent investment in an AI startup.

More interestingly, Arash and I attended the same school. He was our upperclassman and later became our teacher after winning a national gold medal. We share a lot of memories together, and we talk about some funny ones in the interview!

I hope you find this interview enjoyable. You can find the trailer of the interview below.

Trailer

And here is the full interview:

Full Interview Video

PS: As always, feel free to suggest who you’d like me to interview in the comments below.​

Full text and comments »

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

By Shayan, 2 months ago, In English

Hi,

We had a problem-solving session on graph algorithms today. I selected problems that don’t require many prerequisites and are focused on generating ideas. I hope you find it enjoyable and educational.

This video is for people from starter to expert level.

330B — Road Construction

In this problem, we use a constraint on m that helps us solve it easily.

The link to the problem: https://codeforces.net/problemset/problem/330/B

Video

687A — NP-Hard Problem

In this problem, you’ll get familiar with the concept of a vertex cover, and we’ll apply what we’ve learned about bipartite graphs.

The link to the problem: https://codeforces.net/problemset/problem/687/A

Video

1093D — Beautiful Graph

The idea of the previous problem helps a lot to solve this one as well.

The link to the problem: https://codeforces.net/problemset/problem/1093/D

Video

369C — Valera and Elections

In here, we use a trick that is useful in many tree problems.

The link to the problem: https://codeforces.net/problemset/problem/369/C

Video

429A — Xor-tree

Here, we see how to pass the state in DFS and use logical arguments and facts to solve the problem.

The link to the problem: https://codeforces.net/problemset/problem/429/A

Video

105053E — Expanding STACKS

This is a problem we came across recently while practicing for ICPC. We’ll see how graph algorithms can be used to solve a problem that doesn’t initially seem like a graph problem.

The link to the problem: https://codeforces.net/gym/105053/problem/E

Video

I hope this stream and the consequent ones will be helpful.

Full text and comments »

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

By Shayan, 3 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2009A — Minimize!

Video

2009B — osu!mania

Video

2009C — The Legend of Freya the Frog

Video

2009D — Satyam and Counting

Video

2009E — Klee's SUPER DUPER LARGE Array!!!

Video

2009F — Firefly's Queries

Video

2009G — Yunli's Subarray Queries

Video

Full text and comments »

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

By Shayan, 3 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2007A — Dora's Set

Video

2007B — Index and Maximum Value

Video

2007C — Dora and C++

Video

2007D — Iris and Game on the Tree

Video

2007E — Iris and the Tree

Video

2007F — Eri and Expanded Sets

Video

Full text and comments »

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

By Shayan, 3 months ago, In English

Hi,

This is our second stream on Graph Algorithms, where we continued covering the basics. The next stream will be more challenging, as we’ll solve several problems from Codeforces. As mentioned earlier, in future streams, I plan to explain some of the hardest graph problems I’ve ever encountered.

If you’re already at an advanced level, this topic stream is not for you.

Bipartite Graphs

In this section, I discussed bipartite graphs: what they are, the condition for a graph to be bipartite, and how to find the two parts if a graph is bipartite.

Video

Terminology Overview: Walk, Path, and Cycle

To continue our discussion, it’s important to familiarize ourselves with some basic terminology. Here, I define what a walk, a path, and a cycle are.

Video

Find distances and BFS

In this section, we discuss how to find the distance between two vertices in an undirected graph. I first explain the algorithm and then reveal its name—BFS.

Video

Solving a 1600 Difficulty BFS Problem from Codeforces

In this section, we solve a problem that’s perfect for implementing BFS:

https://codeforces.net/problemset/problem/601/A

Video

I hope this stream and the consequent ones will be helpful. Feel free to criticize. I'll do my best to address any issues.

Full text and comments »

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

By Shayan, 3 months ago, In English

Hi,

We had our first topic stream on graph algorithms yesterday.

Since this was the first stream on this topic, I started with the very basics. We’ll cover more advanced topics in the upcoming streams. My goal is to eventually cover every graph algorithm from basic to advanced. In future streams, I plan to explain some of the hardest graph problems I’ve ever encountered.

If you’re already at an advanced level, the first topic stream is not for you, as I started from the very beginning to ensure that no prior knowledge is needed to follow along.

What is a Graph

In this section, I introduce what a graph is and how it can be useful. I also discuss the basic types of graphs (un/directed, un/weighted).

Video

How to Store a Graph

The next question is how we can take a graph as input and store it. This is the first step we must take before running any algorithm on the graph.

Video

Connectivity in Graphs and DFS

Here, I discuss the connectivity of a graph, and we solve a problem related to it. At the end, I mention that what we did is called DFS.

Video

Solve a 1400 Difficulty Graph Problem from Codeforces

In this section, we solve a graph problem with a difficulty level of 1400 from Codeforces.

The link of the problem: https://codeforces.net/problemset/problem/505/B

Video

I hope this stream and the consequent ones will be helpful. Feel free to criticize. I'll do my best to address any issues.

Full text and comments »

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

By Shayan, 3 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2001A — Make All Equal

Video

2001B — Generate Permutation

Video

2001C — Guess The Tree

Video

2001D — Longest Max Min Subsequence

Video

2001E1 — Deterministic Heap (Easy Version)

Video

Full text and comments »

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

By Shayan, 3 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, and not as a substitute for the text editorial.

2004A — Closest Point

Video

2004B — Game with Doors

Video

2004C — Splitting Items

Video

2004D — Colored Portals

Video

2004E — Not a Nim Problem

Video

2004F — Make a Palindrome

Video

Full text and comments »

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

By Shayan, 3 months ago, In English
  • Vote: I like it
  • -17
  • Vote: I do not like it