Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя FairyWinx

Автор FairyWinx, 5 часов назад, По-русски

Задача A:

Разбор
Код

Задача B (Автор: TheScrasse):

Разбор
Код

Задача C:

Разбор
Код

Задача D (Автор: sunkuangzheng):

Разбор
Код

Задача E:

Разбор
Код

Задача F (Автор: Vladithur):

Разбор
Код
Разбор задач Codeforces Round 1099 (Div. 2)
  • Проголосовать: нравится
  • +35
  • Проголосовать: не нравится

»
5 часов назад, скрыть # |
Rev. 2  
Проголосовать: нравится +10 Проголосовать: не нравится

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 часа назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

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

  • »
    »
    84 минуты назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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.

»
5 часов назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Решение за NlogC описанное в разборе не заходит даже на C++(почему то работает за 4169 мс) Причем я использовал unordered_set с самописными хешами, что log проевращало в O(1). Если что номер посылки 375550527

  • »
    »
    4 часа назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    Потому что обращение к мапе размера > $$$10^6$$$ — это уже очень долго, а у тебя таких обращений очень много. Оптимизация, что ты оставляешь в мапе только элементы, которые могут получены из первого элемента уже дает 500мс на питоне (да и асимптотика при использовании std::map составляет $$$O(n \cdot log(A) \cdot log(log(A))$$$

»
5 часов назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 203 ms only in Python

»
4 часа назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I think it was a worst contest. The problem B (at least) is not a suitable one at all for the contest. Again perhaps the problem setting was not okey , isn't it?_

»
4 часа назад, скрыть # |
Rev. 2  
Проголосовать: нравится -10 Проголосовать: не нравится

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

»
4 часа назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 часа назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain D? please.

»
3 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

approx how much would F be rated?

»
3 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

btw How much would approx F be rated??

»
3 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how much would F be rated approximately

»
3 часа назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 часа назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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 минуты назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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 минуты назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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 минуты назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

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 :(.