FairyWinx's blog

By FairyWinx, 105 minutes 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
  • 0
  • Vote: I do not like it

»
72 minutes ago, hide # |
Rev. 2  
Vote: I like it +8 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

»
58 minutes ago, hide # |
 
Vote: I like it +1 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

»
28 minutes ago, hide # |
Rev. 2  
Vote: I like it 0 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?

»
22 minutes 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!!

»
18 minutes 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)

»
2 minutes ago, hide # |
 
Vote: I like it 0 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