Sul_A.'s blog

By Sul_A., history, 6 weeks ago, In English

NAOI 2026 is taking place on April 18, 2026, 11 days from when I'm writing this.

If you wish to see your country added to this blog, leave a comment listing your country's team in order, in the following format:

  • Saad Alaarifi (Erering) — 2nd time at NAOI, 1 attempt left
  • Mohammad Alasmari (m5588ohammed) — 2nd time at NAOI, 0 attempts left
  • Almonther Alghamdi (Almonther) — 1st time at NAOI, 1 attempt left
  • Sultan Alaiban (Sul_A.) — 2nd time at NAOI, 0 attempts left
  • Abdullah Alodaibi (Abdullah_Alodaibi) — 1st time at NAOI, 1 attempt left
  • Ahmad Alhussain (Kokobird1) — 1st time at NAOI, 2 attempts left
Country Average of Max. Ratings 1 2 3 4 5 6
Morocco 1733.33 zakI98 YassirSalama4 Medeali medxad abdelhakimlamnaouar Vyaduct
Saudi Arabia 1529.67 Erering m5588ohammed Almonther Sul_A. Abdullah_Alodaibi Kokobird1
Algeria 1162.5 ocelotwasfound au_aquila KhFares mohamedboukerche55 Blidi Abderrahmane_

Full text and comments »

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

By Sul_A., history, 7 weeks ago, In English

In this blog I will write up solutions for some IOI tasks I solved recently because I have too much energy and not enough things to do.

Also I noticed a disturbing trend in CF blogs where grays publish AI generated solutions for problems. So this blog is in part an attack against that.

IOI 2011 Tropical Garden

Here is the statement

Part 1
Part 1.5
Part 2

IOI 2019 Vision Program

Statement

Part 1
Part 2
Part 3
Comment

Wow it's already 2 AM, it's almost been 3 hours. I feel very tired so mission accomplished.

Full text and comments »

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

By Sul_A., history, 5 months ago, In English

I'm currently making a contest, and at the current pace, I'm not gonna make it. The main things I'm struggling with are:

  • Coming up with good ideas quickly.
  • Creating tasks of varying difficulties.
  • Test generation.

Can I get some advice on this?

Full text and comments »

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

By Sul_A., history, 5 months ago, In English

The very first communication task on CF was released nearly 2 months ago on November 3rd 2025, and the first communication task in a rated round was exactly a week later. And still, there is no "communication" tag like there is for interactive tasks. So here will be a list of all communications tasks ever made, sorted by time of release. Updated regularly.

2168A1 - Encode and Decode (Easy Version)

2168A2 - Encode and Decode (Hard Version)

2168B - Locate

2168C - Intercepting Butterflies

2163E - Plegma

2179F - Blackslex and Another RGB Walking

UPD: A communication tag has been added, hooray

Full text and comments »

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

By Sul_A., 6 months ago, In English

As of writing this, the queue is jammed again, which is happening more and more often over time. After trawling through the problemset status, I discovered several disturbing if predictable occurences: many, and I mean \bf{MANY} accounts were \it{clearly} bot accounts.

Of course this is already well known. These are some bot accounts I found just by clicking on random accounts:

wqxbi18084 xitcrqs410

These two accounts in particular are fascinatingly stupid. For whatever reason, the creator(s) of these account decided it would be a good idea to make ChatGPT include the conversation ID in each submission. (The code that appears in the url when you talk to ChatGPT)

I have some theories on why these accounts exist and the people behind them.

1 — Sabotage

This is the most obvious explanation. Someone really wants to tank CF and make it unusable. Most of these accounts solve all day, every day, nonstop, around the clock, intentionally making testing unbearably long.

The person behind the attacks could be a rival judge (which is hilarious) or someone who personally dislikes Mike or another admin.

2 — Testing

Someone is testing the CF servers by filling it with a rush of submissions to see its limit. Or maybe testing LLMs to see which could solve more CP problems.

Personally, this seems like a very disruptive way, especially since doing it with AI accounts seems unnecessary, but it's still plausible somewhat.

3 — Portfolio

Perhaps, these accounts are designed to solve a billion problems, so someone will be able to profit from selling the account. This could be some underground service that sells CF accounts with a high number of problems solved, so the buyer can add it to his/her portfolio.

It would be heartbreaking if this is the case, and sadly I think it's very likely.

Conclusion

The actual source of the accounts could be any subset of the above, even none of them. I would be interested what you think it could be.

Full text and comments »

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

By Sul_A., history, 6 months ago, In English

As the highest non-red, non-alt-account person in the round, I feel it is my duty to supply the community with an editorial.

2168A1 - Encode and Decode (Easy Version)

Editorial

2168A2 - Encode and Decode (Hard Version)

Editorial

2168B - Locate

Editorial

2168C - Intercepting Butterflies

Editorial

Full text and comments »

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

By Sul_A., history, 7 months ago, In English

I was wondering if there is a way to add a test to multiple groups? I have some tests that belong to multiple subtasks and I don't want to duplicate tests. These groups do not depend on each other.

Full text and comments »

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

By Sul_A., history, 8 months ago, In English

Communication problems are problems where agents with fixed programming communicate data with each other under certain conditions. The contestant has to design a strategy the agents can use to communicate successfully.

Examples of communication problems

Communication problems have been added to Polygon a long time ago. I feel like allowing communication problems on Codeforces rounds will allow for really creative tasks, as Codeforces writers are incredibly talented. They don't even have to be "real" communication, it could be just the program outputting the strategy itself, like IOI 2022 Prisoner for example.

\bf{EDIT:} Codeforces will host a testing round on November 3rd, to test communication problems. Dreams do come true ;)

Full text and comments »

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

By Sul_A., history, 8 months ago, In English

I found a very suspicious account that participated in the last educational round:

utkarshkryadav https://mirror.codeforces.com/submissions/utkarshkryadav

This account has a history of weird submissions patterns and solving tasks in a weird order. In the last round, "he" solved A then D then C then B, solving D in 2 minutes and C in 1 minute (!)

In round 1048, "he" solved D then A then C then B. In many rounds, "he" always makes an incorrect submission on A at the beginning, solves something else, then solved A later. "He" also makes a lot of submissions in quick succession.

Full text and comments »

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

By Sul_A., history, 8 months ago, In English

About an hour before the round, a friend told me that there was a Div. 2 today. So out of pure boredom, I decided to participate, because why not. I was 20 points away from CM, and if I just solve A,B,C,D, I shouldn't lose any rating.

So I bought a large coffee, and got to work. I solved A,B,C in 10 minutes and then I started working on D. It took me 27 minutes, a long time considering how simple the solution was, but I kept going. Then I started solving E1. It took me a while to get to the correct observation, and even longer to implement it with all the bugs I was getting. But I kept going. Eventually I solved it.

Now I was really excited. E2 seemed impossible at first, but then I was able to solve it with an alternative bitset solution. But not before getting a wrong answer because I forgot to make the bitset bigger after debugging.

Despite all of these mistakes, I was still top 20 (top 10 if you consider trusted participants). And imagine how high I would have been if I didn't make those mistakes.

It felt like I was on top of the world. I can't describe how it feels to finally be CM after all these years. I skipped F because it looked really hard, so I started chilling until I saw an announcement that made my stomach drop:

Unfortunately, it was discovered only now that the statement was missing an important condition. The correct statement should include the line "The operation 2 can only be applied at most once." The statement will be corrected soon.

We believe this issue affected many participants of this round, and therefore we have to declare this round unrated. We sincerely apologize for this mistake.

All that hard work, all the stars that had to align, all the keystrokes I entered into my laptop, was a waste of time and effort. Why do I even bother? What's the point of it all?

According to Carrot, I would have gained 156 points if those 3 words were in the statement.

I understand some people were affected by this and had their rating drop, but why should I be deprived of points too?

I suggest making the round rated for people with nonnegative deltas. It's only fair to others and myself who have to put up with newbies who don't even know what a 2D array is copy code from some Indian streamer on telegram.

Full text and comments »

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

By Sul_A., history, 12 months ago, In English

Editorial for some of the new CSES tasks. Tasks that are trivial or too similar to already existing tasks are not included.

Every time I solve a new nontrivial task, I will add it here.

NOTE: ONLY READ THE SOLUTIONS IF YOU ARE COMPLETELY STUCK AND OUT OF IDEAS. CSES tasks are the kinds of tasks you can solve at a random time by random chance. You might read a task today and solve it next week. Or next month. Or next 3 months. So read at your own risk.

Sorting & Searching

Distinct Values Subsequences

Dynamic Programming

Mountain Range
Minimal Grid Path

Range Queries

Visible Buildings Queries
Range Interval Queries
Distinct Values Queries II

Mathematics

Next Prime
Permutation Rounds

Sliding Window Problems

Sliding Window Minimum
Sliding Window Distinct Values
Sliding Window Mode
Sliding Window Mex
Sliding Window Inversions
Alternative solutions

Interactive Problems

Hidden Permutation
Colored Chairs

Advanced Graph Problems

Fixed Length Walk Queries

Additional Problems

Bubble Sort Rounds I
Counting LCM Arrays
Subsets with Fixed Average
Two Array Average

Additional Problems II

GCD Subsets

Full text and comments »

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

By Sul_A., history, 13 months ago, In English

This blog will describe an interesting trick I've seen in a few tasks.

This is my first time writing a tutorial blog so sorry if it makes no sense.

$$$2$$$ and $$$3$$$ can build anything you want.

This trick is based on this observation: any number $$$x \gt 1$$$ can be represented as the sum of $$$2$$$'s and $$$3$$$'s.

Proof
Alternate Proof

How do we use this??????

We can use this idea if we take something of some length from somewhere. Often, we can't just look at all the things we can take because it could be too slow. Instead, what if we limit ourselves to taking things of length $$$2$$$ or $$$3$$$?

I know this is very abstract and high-level, but these tasks will show what I mean.

1624E - Masha-forgetful

This is just a very direct application of this trick. Instead of worrying about every substring, we can only account for substrings of length $$$2$$$ or $$$3$$$, since any substring longer than that can be broken down into shorter substrings. So any solution generated with lengths $$$ \gt 3$$$ can also be generated this way. Submission: 313317958

1616D - Keep the Average High

Funnily enough, this problem was released less than 2 weeks before 1624E.

Firstly, let's subtract $$$x$$$ from all the numbers in the array. Now, the condition becomes $$$a_l + a_{l+1} + ... + a_r \ge 0$$$. Now, here's the genius part. Instead of worrying about every subarray, is it possible just to consider subarrays of length $$$2$$$ and $$$3$$$? It turns out, yes. If every subarray of length $$$2$$$ and every subarray of length $$$3$$$ have a non-negative sum, then every subarray has a non-negative sum. (Except for subarrays with one element).

Proof

From here, we can do a simple DP: $$$dp(i, j, k)$$$ is the maximum number of elements we can take from the first $$$i$$$ elements, $$$j$$$ tells us if we have taken $$$a_i$$$, and $$$k$$$ tells us if we have taken $$$a_{i-1}$$$. Submission: 316394601

Conclusion

If there are other tasks, please post them in the comments. My dream would that this trick gets added to USACO Guide.

Full text and comments »

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

By Sul_A., history, 17 months ago, In English

I recently invented a new game called Guess the Statement.

Here's how it works:

  1. Open up a Div. 4 or Div. 3 or Educational.

  2. Do NOT read any of the tasks.

  3. Open the editorial.

  4. For each task, read the code, and try to guess what the statement was.

  5. Read the tasks and see how close you were!

Recommended contests to start with:

I believe this is the only way to enjoy low-rated problems.

Full text and comments »

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

By Sul_A., history, 17 months ago, In English

I found an unusual similarity between three problems: a POI 2016 task, an Educational F, and a Div. 3 G. While these problems are formulated in different ways, they can be solved in incredibly similar ways. I'm not certain the authors were plagiarizing, this could be a case of parallel thinking. Spoilers ahead.

POI 2016 Parade

Author: Unknown

This task was the oldest one. The task can be summed up as follows: Given a tree, choose a path that maximizes the number of "adjacent" edges. "Adjacent" as in one of its endpoints is in the path, while the other is not. The path has to consist of 2 or more nodes.

For a given path $$$v_1, v_2, ..., v_k$$$, the number of adjacent edges is $$$(\sum_{i=1}^{k} deg(v_i) - 2) + 2$$$. This is because for each node, its contribution is its incident edges, except the $$$2$$$ which are on the path. The $$$2$$$ at the end is to compensate for the ends of the path which only have one neighbor in the path. So let $$$dp(u)$$$ be the best path from the node $$$u$$$ to a node in its subtree. The transitions are: $$$dp(u)$$$ = $$$deg(u) - 2 + \max dp(v, 0)$$$, or $$$0$$$ if $$$u$$$ is a leaf. The answer will simply be the maximum $$$dp(u) + 2$$$ or maximum $$$deg(u) + dp(v_1) + dp(v_2)$$$ for $$$v_1$$$ and $$$v_2$$$ being $$$2$$$ distinct children of $$$u$$$. There is an edge case where the tree is a star. (We have to subtract 1 from the answer).

Code

Education Round 74 1238F - The Maximum Subtree (rated 2200)

Author: Roms

The problem is as follows: Define a good tree as a tree such that for each node, we can assign it a segment, and two nodes will share and edge iff their segments intersect. (As in there exists a point that belongs to both of them). You have to find the largest possible good subtree (connected subgraph) of the given tree.

The most crucial observation is as follows: in a good tree, each node has at most $$$2$$$ non-leaf neighbors. Its leaf neighbors will be contained in its segment, and its $$$1$$$ or $$$2$$$ non-leaf neighbors will share one of its endpoints. If there are $$$3$$$ non-leaf neighbors, They would have to form a cycle. So every good subtree corresponds to a path in the original tree, and the value of a path is equal to $$$(\sum_{i=1}^{k} deg(v_i) - 1) + 2$$$. Sound familiar? We can write the same DP, just with $$$-1$$$ instead of $$$-2$$$. Code can be found 296277443

Codeforces Round 991 (Div. 3) 2050G - Tree Destruction

Author: AVdovin

This problem is suspiciously similar to Parade. Given a tree, find the biggest number of connected components you choose a path and delete all nodes and edges in it. This problem is equivalent to the POI problem, the only difference is that you can choose a path with $$$1$$$ node. Code is 296277443. Note: the number of different characters between 296277443 and 296278465 is only 2 (!).

Full text and comments »

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

By Sul_A., history, 2 years ago, In English

Are there some good segment DP tasks on cf?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it