reirugan's blog

By reirugan, 11 months ago, In English

I hope you all enjoyed the contest! Special thanks to

  • djm03178 for suggesting the inclusion of C1, and for helping with test writing on all problems, especially F
  • satyam343 for helping me solve H
  • Dominater069 for providing the idea for one of the solutions to E
  • Intellegent for providing one of the proofs for the solution to D, and for providing the idea for one of the solutions to F
Rate the contest!

A — Shizuku Hoshikawa and Farm Legs

Solution
Rate the problem!

B — Yuu Koito and Minimum Absolute Sum

Solution
Rate the problem!

C1/C2 — Renako Amaori and XOR Game

Solution (Easy Version)
Solution (Hard Version)
Bonus
Rate the problem!

D/F — Rae Taylor and Trees

Solution (Easy Version)
Solution (Hard Version)
Bonus
Rate the problem!

E — Anisphia Wynn Palettia and Good Permutations

Solution
Bonus
Rate the problem!

G — Sakura Adachi and Optimal Sequences

Solution
Rate the problem!

H — Shiori Miyagi and Maximum Array Score

Solution
Rate the problem!

Full text and comments »

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

By reirugan, 11 months ago, In English

Hello, Codeforces!

I am very excited to invite you to my second-ever contest, Codeforces Round 1065 (Div. 3), which will start on Nov/20/2025 17:35 (Moscow time)! In this contest, you will be given 2 hours and 30 minutes to solve 7 problems, two of which have been split into subtasks. The subtasks for a given problem are not necessarily placed adjacently in the problemset.

The round will be hosted by the rules of educational rounds (extended ICPC). Thus, all solutions will be judged on preliminary tests during the round, and after the round, there will be a 12-hour phase of open hacks. After the open hack phase, all accepted solutions will be rejudged on successful hacks. Also, note that there is no score distribution — rank will be determined by number of problems solved, followed by penalty; wrong submissions will incur the usual penalty of 10 minutes, following the rules of educational rounds.

As a reminder, only trusted participants of the third division will be included in the official standings table. This is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in (and solve at least one problem in) at least five rated rounds
  • and not have had a rating of 1900 or higher at any moment in time.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you (unless you register unrated).

Also, note the rule restricting the use of AI. If you are caught breaking this rule, you will be condemned to life spent in prison the basement of some unspecified Codeforces user. Said person's basement is a rather unenjoyable place to live in, so I would advise adhering to the rules.

I would like to thank the following people for helping make this round possible!

Good luck, and have fun!

UPDATE: Due to issues with Cloudflare, the round has been rescheduled for Nov/20/2025 17:35 (Moscow time).

UPDATE: Editorial

Full text and comments »

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

By reirugan, 15 months ago, In English

I hope you all enjoyed the contest!

Rating Predictions
Rate the contest!

A — Blackboard Game

Solution
Rate the problem!

B — Tournament

Solution
Rate the problem!

C — Prefix Min and Suffix Max

Solution
Rate the problem!

D — Binary String Battle

Solution
Rate the problem!

E — MEX Count

Solution
Rate the problem!

F — Minimize Fixed Points

Solution
Rate the problem!

G — Modular Sorting

Solution
Rate the problem!

Full text and comments »

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

By reirugan, 16 months ago, In English

Hello, Codeforces!

I am very excited to invite you to my first-ever contest, Codeforces Round 1034 (Div. 3), which will start on Jul/01/2025 17:35 (Moscow time)! In this contest, you will be given 2 hours and 15 minutes to solve 7 problems.

The round will be hosted by the rules of educational rounds (extended ICPC). Thus, all solutions will be judged on preliminary tests during the round, and after the round, there will be a 12-hour phase of open hacks. After the open hack phase, all accepted solutions will be rejudged on successful hacks. Also, note that there is no score distribution — rank will be determined by number of problems solved, followed by penalty; wrong submissions will incur the usual penalty of 10 minutes, following the rules of educational rounds.

As a reminder, only trusted participants of the third division will be included in the official standings table. This is a compulsory measure for combating unsporting behavior. To qualify as a trusted participant of the third division, you must:

  • take part in (and solve at least one problem in) at least five rated rounds
  • and not have had a rating of 1900 or higher at any moment in time.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you (unless you register unrated).

Also, note the rule restricting the use of AI. If you are caught breaking this rule, you will be met with unfathomable punishments, so for your own well-being, I highly recommend adhering to the rules.

I would like to thank the following people for helping make this round possible!

Good luck, and have fun!

Update: Editorial

Full text and comments »

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

By reirugan, 18 months ago, In English

A lot of people love to talk about cheating, so let's gather all of our opinions into one set of definitely-not-misleading numbers! For the sake of this post, we will define cheating as "anything that violates the Codeforces rules with the intention of affecting the standings," and we will define being caught as "either being banned or having your submissions in a contest skipped." These may not be the most proper definitions, but I think it'll yield the most useful results.

In any given contest, on average what percentage of users (who make at least one submission) cheated during that contest? (This includes users who are caught.)

  • [0%, 1%)
  • [1%, 5%)
  • [5%, 10%)
  • [10%, 20%)
  • [20%, 50%)
  • [50%, 100%]

In any given contest, on average what percentage of cheaters are eventually caught?

  • [0%, 5%)
  • [5%, 20%)
  • [20%, 50%)
  • [50%, 80%)
  • [80%, 100%]

What percentage of active users (who have made at least one in-contest submission in the last six months) have cheated at least once?

  • [0%, 1%)
  • [1%, 5%)
  • [5%, 10%)
  • [10%, 20%)
  • [20%, 50%)
  • [50%, 100%]

Do you think online unproctored competitive programming is doomed?

  • No, online unproctored competitive programming will remain alive
  • No, but only if something is done in the near future
  • Yes, I think in the long term, online unproctored competitive programming will be unviable
  • Yes, I think we are doomed in the very near future (within a year)

What do you think the appropriate punishment for cheating should be?

  • Permanent IP ban on first violation
  • Permanent account ban on first violation, permanent IP ban after multiple violations
  • Temporary ban on first violation, permanent account ban after multiple violations
  • Warning after first violation, temporary ban after multiple violations
  • Warning after multiple violations
  • No punishment (please don't choose this)

What measures should be taken to combat cheating? (You may choose multiple options.)

  • Email/SMS verification on account creation
  • Small monetary fee on account creation
  • Granting well-known figures (setters, coordinators, etc) the ability to ban users freely
  • Proctored contests
  • Banning/skipping more users based on statistical evidence (which may increase false positive rate)
  • Please choose this option if you voted for any of the above, so we can see each result as a percentage

At what levels do you think cheating is a significant issue? That is, what rating are most cheaters able to obtain? (You may choose multiple options.)

  • Gray/green
  • Cyan/blue
  • Purple/yellow
  • Red/nutella
  • Please choose this option if you voted for any of the above, so we can see each result as a percentage

At median, how much rating do you think a cheater gains, compared to their actual competitive programming level?

  • [0, 200)
  • [200, 500)
  • [500, 1000)
  • [1000, inf)

Which of the following forms of cheating do you think occur at a widespread level? (You may choose multiple options.)

  • Using generative AI to assist with solutions
  • Receiving solutions from YouTube or similar streaming platforms
  • Receiving solutions from private Telegram chats or similar
  • Discussion with much stronger users (unpaid)
  • Discussion with much stronger users (paid)
  • Discussion with users of a similar level
  • Please choose this option if you voted for any of the above, so we can see each result as a percentage

At median, how much rating do you think a legitimate gray/green contestant loses due to cheating?

  • [0, 50)
  • [50, 100)
  • [100, 200)
  • [200, inf)

Feel free to suggest more questions (or more answer choices) in the comments; I'll add anything I see.

Full text and comments »

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

By reirugan, history, 19 months ago, In English

Last weekend I finally hit CM, and today I reached a rating of over 2000, so in celebration, here's a list of some things I've heard of but don't know. I'm relatively new to CP—I started in August 2024—so there are a lot of techniques that most people probably consider standard that I'm not familiar with; feel free to comment below with more suggestions. (This definitely is not a copycat of a certain other famous blog, I swear this is a completely original idea.)

  • Lazy propagation in segment trees
  • Fenwick trees
  • Sparse table
  • Sqrt decomposition
  • Mo's algorithm, which cost me an ICPC solve
  • Small-to-large merging
  • Binary search trees, including treaps
  • Heavy-light decomposition
  • Binary lifting
  • I've never implemented most graph algorithms, including Kruskal's/Prim's, Bellman-Ford, Floyd-Warshall, etc
  • I don't think I've ever implemented BFS before, although I know the general idea
  • Actually I don't think I've ever implemented any $$$O(n\log{n})$$$ sorting algorithm before; I just use std::sort()
  • Flows (I don't even have the slightest idea of what this is)
  • Ternary search
  • Chinese Remainder Theorem (I have a vague sense of what it is, though)
  • Convex hull
  • Fast fourier transform
  • Pretty much any geometry
  • Any string algorithms (although I'm familiar with the general idea of some of them)
  • Anything about hashing
  • How to compute binomial coefficients of large numbers quickly (is this possible?)
  • Every single thing in this list

Just as a bonus, I don't think I've ever AC'd a problem during contest using either DSU or segment trees. As a second bonus, I also do not know how to install C++, use the command prompt, use Github, or write legible code.

Knowing techniques can be useful, but in general I think it's possible to hit CM (perhaps even Master) with only knowledge of basic programming (I/O, control statements, etc), what's provided in C++ standard library (vectors/arrays, sets/multisets, sort(), etc), DP, and some basic combinatorics.

Full text and comments »

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

By reirugan, 20 months ago, In English

(This isn't supposed to be a serious post, but hopefully somebody finds it funny)

Intellegent: are you ok

Intellegent: i think you need some therapy man

Some of my submissions: (all of these were submitted in rated contests and AC'd, and none were intentionally written poorly)

2022C - Gerrymandering:

My submission:

2053C - Bewitching Stargazer:

My submission:

2057C - Trip to the Olympiad:

My submission:

2063D - Game With Triangles:

My submission:

If I can read it, surely it's fine... right? After all, that's all that really matters.

(I would seriously question the judgment of anybody who hires me to write code, ever.)

Full text and comments »

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

By reirugan, 21 month(s) ago, In English

Anyways, I was upsolving 2061E - Kevin and And from yesterday's round, and my friend Lilypad later upsolved the same problem. My submission (in C++) AC'd in 624ms; his (in Java) TLE'd on test 3. Curious if this was an algorithmic issue or a Java overhead issue, I tried re-implementing my C++ solution into Java, and it AC'd in 1515ms. I also tried re-implementing his Java solution into C++, and it AC'd in 1765ms. So it seemed to be a combination of both Java overhead and an algorithmic issue. But upon examination, it seemed like both of our solutions should have the same runtime— $$$O((m+n)2^m + nm\log{nm})$$$. We both tried to find some constant-factor improvements, but no dice—still TLE on test 3.

But one difference I noticed between our codes is that I like to abuse bitwise operators whenever I can, whereas he tends to use mathematical operations instead. Surely the compiler takes care of that, right? I was under the impression that GCC does this, at least. But seeing as I'm not that familiar with Java, I figured I'd test it. I changed a temp % 2 to a temp & 1 in the $$$O(m2^m)$$$ portion of the code, and lo and behold, it AC's! See 302295478 and 302296599 —the only difference is the above.

I tried making several similar changes, such as changing temp /= 2 to temp >>= 1 in the $$$O(m2^m)$$$ portion of the code, which led to an 141ms improvement, and changing limit *= 2 to limit <<= 1 in the $$$O(m)$$$ portion of the code, which led to another improvement of 31ms. I made these three changes to my C++ implementation of his initial algorithm as well, and the runtime improved from 1765ms to 1624ms. See 302291826 and 302298462 —the only differences are the three above. (The constant-factor improvements mentioned in the first paragraph further improved this to 718ms in C++—as expected, not much different from my initial submission.)

From this, I infer that, contrary to my initial belief, neither GCC nor the Java compiler optimizes mathematical operations involving powers of two to bitwise operators. If somebody has another explanation for this behavior, let me know. In any case, I would advise everybody to use bitwise operators whenever possible, as they seem to be substantially faster than their mathematical counterparts.

Full text and comments »

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