Congratulations Nyemot for reaching master this past rollback! God only knows how hard it is in this $$$AI$$$ era
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | jiangly | 3673 |
| 3 | Kevin114514 | 3659 |
| 4 | maroonrk | 3357 |
| 5 | Um_nik | 3354 |
| 6 | squareOf105 | 3348 |
| 7 | tourist | 3346 |
| 8 | strapple | 3338 |
| 9 | heuristica | 3322 |
| 10 | turmax | 3293 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 144 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | BledDest | 133 |
| 9 | maroonrk | 132 |
| 10 | Proof_by_QED | 131 |
Congratulations Nyemot for reaching master this past rollback! God only knows how hard it is in this $$$AI$$$ era
The other day I came up with a problem and I'd appreciate some honest feedback as to whether or not it's a good (enjoyable/interesting) problem. I'd also appreciate it if you could gauge its difficulty by voting below. And I'd appreciate any feedback.
Problem Statement:
You are given an integer $$$n$$$ where $$$1 \le n \le 2000$$$. Consider a square grid with $$$n$$$ rows and $$$n$$$ columns. You are tasked with arranging the first $$$n^2$$$ whole numbers (that is, the integers $$$0, \,1, \,2 \,...\, n^2 - 3,\,n^2 - 2,\,n^2 - 1$$$) inside the grid, with exactly one number on each cell of the grid.
A frog starts in the bottom-left cell of the grid. The number of the cell the frog is currently on will tell the frog a magnitude and a direction to jump. Specifically, say the frog is at a cell that contains the number $$$a$$$.
The frog will then jump a magnitude of $$$\lfloor \frac{a}{4} \rfloor + 1$$$ units in the direction of $$$a \mod 4$$$.
As for the direction, let a value of $$$0$$$ represent a jump to the right, a value of $$$1$$$ represent a jump upwards, a value of $$$2$$$ represent a jump to the left, and a value of $$$3$$$ represent a jump downwards.
For example, if the frog is currently on a cell with the number $$$9$$$, then the frog will jump $$$\lfloor \frac{9}{4} \rfloor + 1 = 3$$$ units and in the upwards direction, since $$$9 \mod 4 = 1$$$, and $$$1$$$ represents a jump upwards.
Starting at the bottom-left cell, the frog will make a series of jumps around the grid based on the number in his current cell. However, if the frog sees that his next jump will lead him off of the grid, then he will not make that jump and stop in his current cell permamently.
Your task is to find and output the maximum number of jumps the frog can perform, given that he starts off in the bottom-left corner. The frog does not want to jump forever; he wants to perform the maximum finite number of jumps.
You also should output a grid where, if the frog were to start in the bottom-left cell of the grid, he could make that maximum number of jumps, without jumping forever. If multiple grids allow for maximum jumps, you can output any.
Input:
a single integer $$$n$$$ where $$$1 \le n \le 2000$$$.
Output:
a single integer representing the maximum number of jumps the frog can perform without jumping forever followed by any $$$n \times n$$$ grid that allows the frog to perform exactly that many jumps.
For example, if $$$n = 3$$$, the frog can make $$$7$$$ jumps with the grid
4 3 7
8 0 6
5 1 2
and it can be shown that you cannot do better than this.
Here is a visualization:

The frog stops at the cell labeled $$$8$$$ as such a jump would throw him off the grid.
This problem is:
This problem's difficulty most closely aligns with:
First, let's handle the $$$n = 1$$$ case, as the frog will make exactly $$$0$$$ jumps, since the number $$$0$$$ would send him off of the grid. So the answer is $$$0$$$ and the grid is also just $$$0$$$.
For $$$n \ge 2$$$, notice that a lot of numbers will immediately throw the frog off the grid, no matter where the frog is currently. Specifically, any number with a jump magnitude greater than $$$n - 1$$$ will always throw the frog off of the grid.
The lower bound for these numbers is $$$4(n - 1)$$$, since $$$\lfloor \frac{4(n - 1)}{4} \rfloor + 1 = n$$$. The number directly below it, $$$4(n - 1) - 1$$$, is the highest number to have a jump magnitude less than or equal to $$$n - 1$$$, and is therefore the highest possible valid jump.
It should also be pointed out that $$$4(n - 1) - 1 = 4n - 5 \le n^2 - 1$$$ for all $$$n \ge 2$$$, so the maximum jump that won't throw the frog off the grid, $$$4n - 5$$$, is always present for grids with $$$n \ge 2$$$.
Therefore, the only numbers that can be included in the frog's path are from $$$0$$$ to $$$4n - 5$$$, inclusive. This is $$$4n - 4$$$ total numbers, giving us a potential of $$$4n - 4$$$ jumps. But can $$$4n - 4$$$ jumps ever be made? Since $$$4n - 4$$$ is a multiple of $$$4$$$, every jump with some magnitude in some direction will always have a counterpart: a jump with the same magnitude in the opposite direction. For example, $$$0$$$'s counterpart is $$$2$$$ and $$$1$$$'s counterpart is $$$3$$$. So, if the frog were to use all $$$4n - 4$$$ jumps, the jumps would cancel out, and he would end up exactly where he started, which would lead to an infinite number of jumps / a cycle.
So, at most, we can use $$$4n - 5$$$ jumps. It turns out that this can always be done for $$$n \ge 2$$$ with the following construction:

Basically, the frog makes jump to the right of magnitude $$$n - 1$$$, then to the left of $$$n - 2$$$, then to the right $$$n - 3$$$, etc down to a jump either left/right (depending on the parity of $$$n$$$) of magnitude $$$1$$$. Now the frog is close to the center column of the grid (slightly to the right for even $$$n$$$).
Then the frog makes a jump upwards of magnitude $$$n - 1$$$, then a jump downwards of magnitude $$$n - 2$$$, then up $$$n - 3$$$, etc down to a jump either upwards or downwards (depending on the parity of $$$n$$$) of magnitude $$$1$$$. Now the frog is close to the center of the grid.
Next, the frog "reverses" the sequence of horizontal jumps, as seen in the image. After doing so, the frog is on the left side of the grid again, and all of the valid horizontal jumps have been used (for each magnitude, either its right jump was used at the bottom row and its left jump at the center row, or vice versa).
Finally, the frog reverses its sequence of vertical jumps, as seen in the image. Except it can't make the final jump downwards with magnitude $$$n - 1$$$, as that would lead it back to its original position. We have used exactly $$$4n - 5$$$ jumps.
...
But wait! For $$$n = 2$$$, this construction would yield the grid
3 2
0 1
which creates a cycle.
For $$$n \ge 3$$$, the construction always works, as you can always put a number with a jump magnitude of at least $$$n$$$ in the top-left corner, and the frog will stay there permanently (this is because, for $$$n \ge 3$$$, $$$4n - 5 \lt n^2 - 1$$$, meaning that the first number with jump magnitude of $$$n$$$, $$$4n - 4$$$, is always present for grids with $$$n \ge 3$$$).
But for $$$n = 2$$$, the answer can't be $$$3$$$, as the final jump would always lead to a cycle. The answer can't be $$$2$$$, either, as attempting to create such a grid would create a cycle:
2 3
0 1
Thus, the answer must be $$$1$$$:
2 1
0 3
The end.
Bonus: can you solve it so the frog jumps the (finite) maximum number of units?
Maybe this isn't news to some people here, but it was kind of surprising to me. These are the standings of cf round $$$1085$$$ (unofficial standings):

The account tickcross.y (ranked 9th officially) seems suspicious to me, going from around $$$1000^{th}$$$ place in div $$$3$$$ s to $$$9^{th}$$$ place in a div $$$1$$$ in just a few months. If I were to guess, I would say that this guy is a cheater, but okay there is a slight chance that it is some high-rated user messing around.
Also, I think that the account ChatGPT4.0 ($$$1^{st}$$$ place unofficially) is an account dedicated to testing $$$AI$$$ models, so I think that there is a good chance that this user used some $$$AI$$$ model (probably an expensive one for the time being) to $$$AK$$$ the contest unofficially.
I guess this means that soon the ratings here really will be close to meaningless throughout the entire rating range. The skills gained through actual effort won't be meaningless, but the actual rating will be, and that is kind of disappointing.
cf contests these days
First of all, it seems like the plagiarism checker isn't doing a great job at removing a good portion of the $$$AI$$$ cheaters. It is alright, but it isn't great. And as $$$AI$$$ tools get better (and cheaper), the amount of cheaters in the top $$$1000$$$, $$$500$$$ and $$$100$$$ spots in $$$div$$$ $$$1+2$$$ s will increase.
In my opinion, I don't see any way to reliably automate the removal of $$$AI$$$ cheaters. You pretty much need actual people to look at potential cheaters and determine if they are actually cheating.
Of course, the codeforces admins don't have the time or resources to do all of this by themselves (that is, look at all of the potential cheaters and then ban the ones that they determine are actually cheating). But the cf community actually can do this, and I think that some members would enjoy doing this. There is already a pretty good cheater database out there, and a lot of the cheaters in it have not been officially caught by cf, so the community is definitely capable of identifying cheaters that codeforces itself isn't identifying.
So I think that codeforces should give the community limited permission to ban users. This would have to be done in a careful way, though, like maybe there are $$$4-6$$$ trusted community members that can vote on banning a certain user, and if the vote to ban them is unanimous, the user gets banned. The admins wouldn't even have to do anything.
It doesn't have to be done that way, though, like another way to do it would be to just ban everyone in the current cheater database. If the database is carefully maintained, this would also not be a bad option, in my opinion.
My point is that if we continue to leave most (all?) of the banning up to the admins, a good deal of cheaters simply won't get caught. And since codeforces has an active community that cares a lot about identifying and banning cheaters, not using the community to directly assist in banning cheaters is a waste. That is all.
hopefully

“For God so loved the world that He gave His one and only Son, that whoever believes in Him shall not perish but have eternal life.” — John 3:16
I think that it would be convenient to have a feature that allows you to filter problems based on whether or not they appeared in a rated contest. Because problems that have appeared in unrated contests (referring to ICPC mirrors and such) are usually like $$$500+$$$ points overrated, so when you filter by rating, you basically have to ignore these problems.
I thought of this problem a while back, but I'm not sure if it has been created before. Anyway, I think that it is a pretty fun (possibly easier) problem, but I might be a bit biased. I'd appreciate it if you could give it a try and rate it. Also, maybe someone can find a simpler proof for it.
Problem statement:
A derangement of length $$$n$$$ is a permutation $$$p$$$ where $$$p_i \ne i$$$ for all $$$1 \le i \le n$$$.
You are given an integer $$$n$$$. You have to count the number of permutations $$$p$$$ of length $$$n$$$ that can be converted into a derangement using the following operation some (possibly $$$0$$$) number of times:
For example, $$$p = [1, 2]$$$ would be counted for $$$n = 2$$$ as you can pick $$$l = 1,\,r = 2$$$ and transform the permutation into $$$[2, 1]$$$.
Constraints: $$$10$$$ testcases per test, each consisting of a single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$.
Examples:
$$$n = 1$$$ gives $$$0$$$, as $$$[1]$$$ cannot be converted into a derangement.
$$$n = 2$$$ gives $$$2$$$, as each permutation can be converted into a derangement.
$$$n = 3$$$ gives $$$5$$$. The only permutation that cannot be converted is $$$[3, 2, 1]$$$.
For even $$$n$$$, choosing the entire array in one operation will always turn it into a derangement. Therefore, the answer for even $$$n$$$ is just $$$n!$$$.
However, this does not work for odd $$$n$$$, because $$$\lceil \frac{n}{2} \rceil$$$ will fall into its corresponding index. Call this pivot value $$$v$$$. Notice that if $$$p_v = v$$$ and we can't move $$$v$$$ out of the $$$v^{th}$$$ index, then we can't turn $$$p$$$ into a derangement.
When does this happen? Well it must be the case that $$$p_v = v$$$ initially, all of the values to the left of $$$v$$$ are greater than $$$v$$$, and all of the values to the right of $$$v$$$ are less than $$$v$$$.
Why? Let's say one of the elements to the left of $$$v$$$ (at index $$$u$$$) is less than $$$v$$$. Then we can just apply the operation on $$$p_{u...v}$$$ and $$$v$$$ will be replaced with $$$u$$$ (or possibly a smaller element between the two indices). A similar argument can be made for the right side of $$$v$$$.
Now let's say the conditions are satisfied. We cannot move $$$p_v$$$ from $$$v$$$ because if we try to sort any subarray including index $$$v$$$, the order of the elements to the left of $$$v$$$ (or to the right of $$$v$$$) may change, but $$$v$$$ will stay in its position.
So now we have a condition where all $$$p$$$ satisfying it cannot be converted into some derangement. It turns out that all $$$p$$$ that don't satisfy the condition can always be turned into a derangement.
Convert the permutation into a simpler array $$$a$$$ where all elements less than $$$v$$$ are $$$0$$$'s, $$$v$$$ is $$$1$$$, and all elements greater than $$$v$$$ are $$$2$$$'s. The number of $$$0$$$'s is equal to the number of $$$2$$$'s. Now let's transform the operation into one that just swaps adjacent elements at indices $$$i, i + 1$$$ if and only if $$$a_i \lt a_{i + 1}$$$.
Notice that arrays of the form $$$[2, 2, \dots, 2, 0, 1, 0, 0, \dots 0]$$$ (form $$$1$$$) or $$$[2, 2, \dots, 2, 1, 2, 0, 0, \dots, 0]$$$ (form $$$2$$$) always represent derangements. For $$$n = 5$$$, these arrays would be $$$[2, 2, 0, 1, 0]$$$ and $$$[2, 1, 2, 0, 0]$$$, respectively.
The original $$$a$$$ won't be of the form $$$[2, 2, \dots, 2, 1, 0, 0, \dots, 0]$$$ (because such an array satisfies the condition). For the remaining arrays, we can either use the operation to push all of the $$$2$$$'s to the left and then position $$$1$$$ in its correct place to make form $$$1$$$, or we can use the operation to push all of the $$$0$$$'s to the right and then position $$$1$$$ in its correct place to make form $$$2$$$.
One of these procedures will certainly work because either the $$$1$$$ will come before a $$$2$$$ (meaning we can achieve form $$$2$$$) or the $$$1$$$ will come after a $$$0$$$ (meaning we can achieve form $$$1$$$).
So all permutations that don't satisfy the condition can be converted into some derangement. Therefore, the answer for odd $$$n$$$ is just $$$n! - (\lfloor \frac{n}{2} \rfloor!)^2$$$.
Vote:
Hello everyone, I think that I might have a good idea to combat some of the cheating in online contests. Basically, we can split the rankings (and rating calculations) of div. 2 rounds into one containing users with $$$1600+$$$ rating and one containing users with $$$ \lt 1600$$$ rating.
Here is why. In div. 1 rounds, there are hardly any cheaters (yes, there are some, but they are few and far between). I think that the reason for this is because, in order to reach div. 1, you have to be a bit serious about competitions. Most cheaters aren't serious enough, as they get caught before they reach div. 1, so div. 1 is left with a bunch of honest participants.
But I think that this holds true for those rated $$$1600+$$$, too. Of course, the cheaters become more frequent as the rating threshold goes lower, but I think that finding a cheater expert is quite uncommon, too. This is shown by the standings of the most recent round: most of the cheaters in the top $$$100$$$ aren't even expert.
Another reason why div. 1 has so few cheaters is because div. 1 only has $$$900$$$ participants each round, so cheaters are much more obvious. If we split the div. 2 rankings like this, the cheaters above $$$1600$$$ would be much more apparent, as there would only be a few thousand participants with ratings above $$$1600$$$ (as opposed to $$$10k+$$$ with how the rankings are split now).
You might say that this is just handing the cheating problem to those with $$$ \lt 1600$$$ rating, but I don't think that this would be the case. I think that cheating below $$$1600$$$ would more or less stay the same, while cheating above $$$1600$$$ would go down a bit due to the increased visibility of each individual cheater (because of the smaller standings table). So the $$$1600+$$$ table would have very few cheaters.
I know that typing isn't really that big of a part in codeforces skill, but I think typing tests are pretty fun.
I'd appreciate it if you tried the test here and shared your results: https://humanbenchmark.com/tests/typing. These are my results 
and I feel like I can code standard algorithms pretty quickly.
This is not that serious of a post, but I feel like this could be a good way to make money. Maybe the people who scam foreigners in Europe can try this to see if it actually works well.
It would work by using the game of Nim. Basically, in the game of Nim, two players take turns removing a positive number of stones from exactly one of some number of piles of stones. The player who can't make a move loses. You can read about it here. Basically, if the $$$XOR$$$ of the number of stones in each pile is greater than $$$0$$$, the player who makes the first move, Alice, can always force a win. Otherwise, Bob can always force a win (because after Alice's turn, the game would transition to a state where the $$$XOR$$$ is greater than $$$0$$$).
So here's what you would do. First, set up a table near some popular site. When someone (Bob) comes your way, explain the rules of the game to them. Then gather $$$30-40$$$ matches and tell them to arrange the matches in $$$4-7$$$ piles however they want. Also, make a bet for some amount of money. Then you make the first move. If you know what you're doing, you will win in most cases, because the probability that the $$$XOR$$$ of the matches is greater than $$$0$$$ is very high. Furthermore, if you have an odd number of matches in total, the $$$XOR$$$ of the piles will always be greater than $$$0$$$, so you can never lose the game as long as you go first.
But this trick has more potential. If they get suspicious that you are making the first move, tell them that they can make the first move (or ask them if they want to flip a coin for the first move). The chance that the $$$XOR$$$ of the match piles is greater than $$$0$$$ after their turn is still very high. And even if it weren't, they would likely make a mistake somewhere along the way, unless they also know what they're doing.
If they lose and they want a rematch but they are suspicious of you, you can switch it around: now the player who makes the last move loses. Luckily, this variant (called a misère game) works almost exactly the same as a Nim game, so you still have a very high chance of winning.
Now if you're at your table alone, no one is really going to approach you. So you should hire a few people to come up and "play" a game with you every now and then so that you seem more approachable. Also, you should lose maybe half of the "games" you play with your employees so that the onlookers feel like they have a chance.
If you combine all of this with a personality that implies that you don't really know what you're doing, I think that you could really make a lot of money. Many people will think that they're smarter than you, but not many will be well-versed in the Sprague-Grundy theorem.
You are given a grid with $$$n$$$ rows and $$$m$$$ columns filled with zeros and ones. In one move, you can choose any cell in the grid and flip all of the bits in the adjacent cells. You do not flip the bit in the cell you chose.
For example, if you choose the cell $$$(3, 1)$$$ and then the cell $$$(2, 2)$$$.
0 0 0 0 0 0 0 1 0
0 0 0 -> 1 0 0 -> 0 0 1
0 0 0 0 1 0 0 0 0
You are given that you can make the grid into all zeros in some number of operations. Find the minimum number of operations to make the grid all zeros and output any minimum sequence of operations.

are they all bots or what?
Hello everyone, these are some cf-related shower thoughts. I must warn you that some of them weren't thought of in a shower, though. If anyone has any ideas they thought of, I'd be interested to hear them.
Shower thoughts:
Pronouncing Euler incorrectly makes Euler Tour sound much more catchy.
It is easier to get a top 1000 placement in div. 1 than it is in div. 4.
Eggs are one of the most wholesome foods for you because, out of them, a whole chicken can be formed, which is not too dissimilar from a human. So they have all the nutrients you need.
Type 1 diabetics are always quick to mention that they have type 1 diabetes as opposed to type 2 diabetes. So people would rather be seen as genetically cursed than fat.
A big portion of competitive programming teaching talent is not having an Indian accent.
That is all.
For an array $$$a$$$, $$$A = \max(a)$$$.
Could such a thing actually be made to be more efficient than normal sorting algorithms?

let us rejoice and be glad in it
It seems clear that one day, possibly in the near future, tourist won't be the only one at $$$4000+$$$ rating. I think that this raises a bigger issue, though: there are too many LGMs. Of course, this is just an opinion, but I don't think that the word "legendary" should be thrown around this often. For example, wrt chess, Magnus Carlsen and Bobby Fischer are legendary. Hikaru Nakamura is very very good, but he is not legendary. Also, I don't think anyone would consider the current world champion Ding Liren legendary.
To be honest, the only person on cf with true legendary status might be tourist. In fact, we can tell that he is the only legendary one because he has his own rank. If any of the other LGMs were legendary, they would also have their own rank (or something like that to signify true legendary status). So maybe $$$3000-3999$$$ should have a different name.
Hello everyone. I came up with this problem today (I'm not sure if it is original, but I really hope it is), and I am just wondering if it would be a good div. 2 A.
Problem statement:
You are given an array $$$a$$$ of distinct elements, and, because you like hygienic things, you want to sort it in ascending order. Unfortunately, you can't run a normal sorting algorithm on the array. In fact, you can only perform one type of operation that goes like this:
Because sorting the array was too easy for you, you decide to challenge yourself by answering $$$n + 1$$$ queries. The $$$i^{th}$$$ query asks the question: can you sort the array $$$a$$$ in exactly $$$i - 1$$$ operations? Note that the queries are $$$1$$$-indexed.
Input:
The first line of each test contains one integer: $$$n$$$ $$$(2 \le n \le 2 \cdot 10^5)$$$, which denotes the length of the array. The next line contains $$$n$$$ space-separated integers $$$a_1, a_2, \cdots a_n$$$ $$$(1 \le a_i \le 10^9)$$$. All $$$a_i$$$ are pairwise distinct.
Output:
For each test, output $$$n + 1$$$ space-separated integers, the $$$i^{th}$$$ integer being the answer to the $$$i^{th}$$$ query. If the answer to the $$$i^{th}$$$ query is true, the $$$i^{th}$$$ integer is $$$1$$$. Otherwise, it is $$$0$$$.
For example, the answer to the array $$$1\,2\,3$$$ would be $$$1\,0\,1\,1$$$, because you cannot sort the array using $$$1$$$ operation, but you can sort it using $$$0, 2, 3$$$ operations.
The problem can be broken down into cases. Let's first consider the case where $$$n \ge 3$$$. This can be broken down into two subcases: $$$a$$$ is already sorted and $$$a$$$ is not sorted.
If $$$a$$$ is already sorted, the answer to the first query is $$$1$$$, but the answer to the second query is $$$0$$$, as in one operation, the array cannot go from sorted to sorted. The answers to the rest of the queries are all $$$1$$$, as we can keep alternating between two different unsorted permutations until we must sort the array with the final operation.
If $$$a$$$ is not sorted, the answer to the first query is $$$0$$$, and the answer to the rest of the queries are all $$$1$$$ based on similar logic.
If $$$n = 2$$$, it is clear that there is only one possible choice each operation. If the array is already sorted in ascending order, then we must sort it in descending order with one operation. This goes the other way, too. Therefore, if the array is already sorted, our answer will be $$$1\,0\,1$$$, and if it is not already sorted, our answer will be $$$0\,1\,0$$$.
I'd also appreciate some feedback if you have the time. If you saw this as a Div. 2 A, would you consider it a bad/average/good problem?
Problem statement:
Unfortunately, your time has come. You have just passed away, and you find yourself standing face to face with God. Since you were a decent person in your life, God decides to give you a choice. He presents you with two options.
Option 1: Your consciousness is destroyed forever. You won't be able to sense anything. You simply do not exist anymore.
Option 2: You roll a fair $$$1\,000$$$-sided die. On $$$999$$$ of the sides, the word heaven is written. On the remaining side, the word hell is written. If the die lands on heaven, you experience eternal bliss and euphoria. If the die lands on hell, you experience eternal torment.
Which option do you choose?
It looks like Rust doesn't have bitset in its std. Is there any alternative?
| Name |
|---|


