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

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

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!

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

Разбор задач Codeforces Round 1065 (Div. 3)
  • Проголосовать: нравится
  • +129
  • Проголосовать: не нравится

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

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

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

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

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

Inspired by various conversations with beginners in Errichto Server Official. Most of this isn't original advice; you can probably find a lot of this in other blogs. But I just wanted to record all of my opinions in a single place so I can link it when I get pinged by beginners on Discord for advice. (Also for farming contribution.)

Should I do CP?

Do CP if and only if you enjoy it. My personal opinion is that the best way to think of CP is like a video game. It might indirectly improve some skills, but that's not really its purpose. Why would you play a video game if you hate it?

But doesn't CP help me get a job?

Maybe a little bit, but there are more efficient ways to improve your job prospects. Make a project or something.

Ok, let's say I enjoy CP. How do I improve at it?

In general, I think that if you enjoy CP, basically any decent practice method will be effective, and if you don't enjoy CP, basically no practice method will be effective. Why? The only way to improve at CP is to engage deeply with problems, and you can't really engage deeply with problems if you don't enjoy them.

Now, let's say that you enjoy CP. What next? When you're in the mood, pick a problem that's maybe a few hundred points above your level, and try to solve it. (Please don't rely on problem sheets; any sort of structured system is ineffective, because practice is highly personal. You can pick a problem with TLE bot in some Discord servers, or just a random problem picker, or just pick one that looks fun.) If you can solve it within some reasonable amount of time, great! If you get bored, stop and do something else. If you want, you can give up and read the editorial, but it's probably best not to do this too often.

A lot of the blogs in the General Advice section of the Catalog tab on Codeforces go more in-depth than I have; you can read them if you want.

But surely I need to learn some things?

If you are doing Codeforces, you really don't need to learn very much. If you are doing OI or ICPC or such, you probably should learn more technique, though.

For Codeforces, the following is an essentially comprehensive list of things you should know if you are CM or below:

  • Basic programming, including I/O, if-statements, for loops, functions (including recursion)
  • How to use C++ STL or similar for other languages (note: you do not have to know how they are implemented, just how to use them); this includes things like vectors/arrays, strings, sets, multisets, maps, and some of the built-in STL functions (I personally find sort() and lower_bound()/upper_bound() to be the most useful, along with maybe swap(), reverse(), and rotate(), but mileage may vary; note that standard library gcd() is bad, and __gcd() is preferable)
  • Some basic combinatorics/number theory, nothing too advanced; basic counting, basic modular arithmetic (including modular inverses), binary exponentiation, definitions and basic properties of graphs/trees, definitions and basic properties of permutations, and basic properties of factorization (including Sieve and GCD/LCM/similar)
  • Binary search
  • Prefix/suffix arrays
  • Basic dynamic programming
  • Definition of basic bitwise operations (AND, OR, XOR) and maybe a few basic properties
  • Depth-first search
  • Maybe Dijkstra, but probably not useful below Expert level
  • Maybe segment tree, but probably not useful below Expert level (unless you're lazy and spam it on everything)

Why not practice every day, all day?

As I said before, I think that the optimal practice frequency is exactly whenever you feel like practicing. If you really want to do problems all day every day, you can do so, but there are very few people like this. Why not practice all the time? Because you only improve when you're engaged in the problems. If you are practicing without being engaged, you are not improving, and you are also burning yourself out, which decreases the quality of your practice later when you are engaged. So don't overpractice. I suspect the majority of Master+ have never practiced daily for an extended period of time (of course, some have, but they are probably a minority). Don't make a specific effort to be "consistent" or maintain your streak or whatever.

Are some people more talented than other people?

This is just my opinion, so take it with a grain of salt. Yes, there is "talent," in the sense of that some people are unable to surpass a certain level. But it's not based on "intelligence" like many people think. To me, a person's "potential" is basically perfectly correlated with how much they enjoy CP. It's hard to force yourself to enjoy something; some people are hard-wired to enjoy certain things more than others. There are definitely many things I don't like doing (I probably don't even like CP problems as much as many people higher-rated than me). If you are unable to enjoy CP, you are probably doomed to remain low-rated forever, so go do something else. On the flip side, if you really really love CP, then you are one of these rare people who might be able to hit LGM someday, so keep going at it!

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

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

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

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!

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

Разбор задач Codeforces Round 1034 (Div. 3)
  • Проголосовать: нравится
  • +292
  • Проголосовать: не нравится

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

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

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

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

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

that

set<int> a;
int val;
// whatever
lower_bound(a.begin(), a.end(), val);

is not the same thing as

set<int> a;
int val;
// whatever
a.lower_bound(val);

Quite an unfortunate way to TLE in a contest... but at least now I know! (I'm upset anyways.)

For those of you who are uninformed of how lower_bound() works (like I was an hour ago)...

lower_bound(a.begin(), a.end(), val);

only runs in $$$O(\log n)$$$ time on random-access iterators, such as those in a vector. In particular, this will run in $$$O(n)$$$ time on sets and maps. For sets and maps, you have to use the lower_bound specifically for that data structure.

Anyways, I'll never do this again...

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

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

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

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.

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

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

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

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.

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

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

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

(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 - Джерримендеринг:

My submission:

2053C - Очаровательный звездочет:

My submission:

2057C - Поездка на олимпиаду:

My submission:

2063D - Игра с треугольниками:

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.)

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

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

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

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.

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

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