Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

FairyWinx's blog

By FairyWinx, 5 hours ago, translation, In English

Problem A:

Editorial
Code

Problem B (Author: TheScrasse):

Editorial
Code

Задача C:

Editorial
Code

Problem D (Author: sunkuangzheng):

Editorial
Code

Problem E:

Editorial
Code

Problem F (Author: Vladithur):

Editorial
Code
  • Vote: I like it
  • +35
  • Vote: I do not like it

»
5 hours ago, hide # |
Rev. 2  
Vote: I like it +10 Vote: I do not like it

For problem C it says the Time Limit is 2 sec for every test, however in my solution I iterate over $$$N(\le10^5)$$$ and for each iteration I simulate the crunching procedure, $$$a_i$$$ which can go upto $$$10^9$$$ in worst case, and will take only $$$2log(H)\times(log(N\times(log(H)))$$$ ops, $$$2log(H)$$$ out of it are simulation steps and $$$(log(N\times(log(H))$$$ is the number of ops needed for updates in std::map, where $$$H(\le10^9)$$$, and the map size will be $$$N\times2log(H)$$$, so the time complexity should be $$$O(N\times2log(H)\times(log(N\times(log(H))))$$$, which translates to roughly $$$1.3\times10^8$$$ ops $$$\le$$$ $$$2\times10^8$$$ ops since Time Limit was 2 sec this shouldn't TLE.

Also Explanation for C in Edi isn't showing up.

xoxo and FairyWinx please look into the issues for 2231C - Chipmunk Theo and Equality

  • »
    »
    2 hours ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I created video editorial for C. Chipmunk Theo and Equality.

  • »
    »
    84 minutes ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    With the help of ChatGPT, I realized that using two separate maps is twice as slow. Chat told me to use a map<ll, pair<ll, ll>>. Of course it's actually unordered_map<ll, pair<ll, ll>, custom_hash> mp;

    The point is, using 1 map is going to save you twice the time. The editorial uses 2 which is bad, but it is better for intuitively teaching the solution.

»
4 hours ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

I have an interesting solution for C.

If we fix the parity of the final answer to be odd or even, then there is a greedy way to achieve it in minimum operations.

Takes 250 ms only in Python

»
4 hours ago, hide # |
Rev. 2  
Vote: I like it -10 Vote: I do not like it

I think that it was a worst contest. Choosing problems for every position(specially for B) was really inappropriate , isn't it?

»
4 hours ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Problem C has quite an interesting TL Limit 375594227 had to optimise it to the bone with unordered_map (even multiple unordered_maps TLed) but somehow passed , preety much kept all possible elements and the cost required for each element to reduce to all elements they can reach and then found best answer among all values which all elements can be reduced to.

A more elegant solution i did during the contest 375535979 where i simulated from the largest value mentioning this as i have no clue what the tutorial has written. Hope it helps!!

»
4 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Could someone recommend problems that use the same idea as F ? (Specifically the theorem mentioned)

»
4 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I have an interesting solution for C. Construct a graph that represents the procedure mentioned in the problem. Like 9 -> 10 -> 5 -> 6 -> 3 -> 4 -> 2 -> 1. Imagine doing this for all natural numbers. The graph formed is almost a tree but it has an issue that there is an edge from 1 to 2 and also an edge from 2 to 1. So basically we can find the LCA(lowest common ancestor) of all the elements of the input array in this tree(assuming it's rooted at 1). And then we can calculate number of moves needed to reach this number(the LCA). Since there can be some trouble with 1 or 2. We check for 1 and 2 separately. Implementation

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can someone explain D? please.

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

how much would F be rated approximately

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

C makes us realize that we should not use map blindly. For instance, one could have used an array nd for each index store possible values instead of using map.

»
2 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

I find it strange that the intended solution for C was not to just simulate the process (or that no one else mentioned a similar solution). My solution 375495693 did just that in O(nlog(n)log(C)). It simulates in a greedy way using a priority queue while keeping track of the smallest and biggest element and exiting the simulation once the smallest value was one less than the biggest (a special case for 1, 2 was needed tho).

I guess this goes to show how bad the maps are.

  • »
    »
    94 minutes ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I upsolved C and I just simulated the problem (now I'm thinking why everyone is talking abt map here) without any map or other data structure. My approach is just take the min element and generate all possible nums till 1. Now these numbers are our target nodes and now we can just solve the problem like Multi source BFS. 375678399

»
72 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Hey I am able to see this "Rating changes for last rounds are temporarily rolled back. They will be returned soon" Is it only for me or everyone is seeing it?

»
64 minutes ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

Problem F seems easier than usual, felt bad.

1) Every number can be represented as atmost sum of 4 squares — This is just theory
2) Then finding answers for 1,2 are very easy, case 3) is the trick part which could also be solved after some thinking.

Usually F problems are very hard in div 2 contests, but this one is not the case :(.