Recent Learnings and Contests
Ehhh, all of these should’ve been separate blogs. But I was too lazy, and I don’t want to do my art assignment so here we are.
10/24 Round 904 (Div 2) Virtual
Virtual Rank: 997 (According to Codeforces Anytime)
AC Count: 3 / 5
This was one of the contests held in 10/22. pA and pB aren’t really hard so I’m not gonna go over them here.
pC was a interesting one, because it is really similar to E2. Array and Segments (Hard version), and I tried to just do the segment tree solution I used in it, but got TLE for some reason. After a few attempts and optimizations, I did pass this problem.
pD is a hard problem in my opinion. I originally thought of mobuis function, but it wasn’t the case. I didn’t solve this in contest, and I suffered from this problem for like two more days. I’m really not that good at number theory :(.
10/24 Round 905 (Div 2) Virtual
Virtual Rank: 131 (According to Codeforces Anytime)
AC Count: 6 / 7
I absolutely cooked this round. I got 2174 performance, which is the highest I’ve ever gotten.
In my opinion, E > B > A > C >= D2 > D1, which is a really weird distribution.
pA asks if we can make a string into a palindrome when we remove elements. I definitely over thought this question when in the editorial, it was sufficient to check if the number of odd occurences is not greater than .
1 | void solve() { |
pB was a really tricky one. The problem gives you an array of integers, and you have an operation . It asks the minimum number of operations that makes the product of the array divisible by ).
The first idea is we can make the array into ,
because of the fact that .
Obviously, if there is a in the array, the answer is .
Else, we want to try to find the number that is closest to (so we can do the operation until it is k).
But this does not work in all cases, for example, , the answer should be (add 1 on both elements).
I was stuck we for a while, but notice the constraint for ! It turns out, the case I mentioned would only occur for ! for , we can just check it as usual, while we need to also check the way to make 2 2’s when .
1 | void solve() { |
pC was extremely easy for me. I solved it in under 7 minutes!
The problem is: Given an array, calculate the number of subarrays such that it occurs in the array as a subsequence exactly once.
Lets say if we have a subarray , if this subarray occurs in the array as a subsequence more than once, this implies that there exists (at least) one s.t , or (at least) one s.t , or even both.
So, we can find candidates for left/right end point by checking if there isn’t the same element on its left/right.
Example:
-> the array
-> potential left endpoint candidates
-> potential right endpoint candidates
Then the answer is just the sum of for each end point, the number of right candidates on its right.
We can calculate this quickly by using an prefix sum.
1 | void solve() { |
(2024/02/20 edit) I actually noticed I haven’t finished this yet… maybe one day…?
