Codeforces Round 1109 (Div. 3) Participation Record
It’s me.
I participated in Codeforces Round 1109 (Div. 3). I solved 4 problems. Problem C was more difficult than Problem D. Since I have a constraint where I can’t use my computer after 1:00 AM, I’m sad that I usually can’t participate for the full duration.
By the way, I forgot to comment out itertools again this time. I thought I checked it, though…
Problem A Iskander and Drawings
There might be a cleverer way, but I solved it using Run-Length Encoding.
Problem B Nikita and Books
I struggled with this for a while. Instead of thinking about a specific method, judging based on whether it is theoretically possible worked out well.
- Create a prefix sum array of .
- Create a prefix sum array of array .
- Output
Yes/Nobased on whether is satisfied.
I’ll write something like a simple proof:
The simplest form of the array we want to create is . Therefore, I think it’s sufficient to just judge whether that can be created. (It’s probably correct.)
Problem C Stepan and Permutation
Personally, I found this problem to be the most difficult. If I were to name a similar problem, would it be Codeforces 1103 - B? Actually, checking the problem again, it might be completely different.
Well, please forgive me since the line of thinking is similar.
First, let’s consider the case where .
- Let .
- Output
Yes/Nobased on whether is satisfied.
Next is the case where .
Since and are coprime, we can change the . However, we need to consider whether it can be changed freely. While unproven, I feel like it can be changed if . And that is satisfied by the constraints.
You can solve it using these ideas.
Problem D Yaroslav and Productivity
I feel like this has appeared in a contest somewhere every week for the past three weeks. Yes, it’s Reading Queries in Reverse.
-
Create a prefix sum array of .
-
Sort in ascending order.
-
Add to the beginning of , and repeat the following operations by taking from the end of :
- Add .
-
Finally, add .
In terms of image, it feels similar to ABC466 - E, but DP is impossible here due to constraints.
If you flip the signs of all values in a certain range, the sign of the total sum in that range flips. Therefore, we manage the total sum of the range using prefix sums.
By looking from the back, you can finalize the values of the ranges seen so far. Therefore, you should greedily take the larger one for a certain range.
I ran out of time here, so I couldn’t solve Problem E and onwards.
As I wrote at the beginning, I really checked the itertools comment-out properly this time, but as usual, I feel it’s a waste to get a penalty for this…
Should I create an environment specifically for Codeforces? Hmm…
Well then, see you later.