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

Автор MikeMirzayanov, 5 лет назад, По-английски

Thanks for taking part in the round. I hope you enjoyed the round. It happens that the statements were really easy to understand (thanks to testers). We've got only 38 questions during a round!

Tutorial is loading...
Code
Tutorial is loading...
Code
Tutorial is loading...
Code
Tutorial is loading...
Code
Tutorial is loading...
Code
Tutorial is loading...
Tutorial is loading...
Code
Tutorial is loading...
Code
Разбор задач Codeforces Round 547 (Div. 3)
  • Проголосовать: нравится
  • +39
  • Проголосовать: не нравится

»
5 лет назад, # |
Rev. 3   Проголосовать: нравится +1 Проголосовать: не нравится

MikeMirzayanov, in code of 1141B - Maximal Continuous Rest should be if (a[i % n] == 1) but there is if (a[i % 2] == 1).

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

Thank you so much MikeMirzayanov for this round... I enjoy the problems a lot...

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

E can be solved using binary search also .

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

Thank you for this good editorial.

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

Can someone please this, why I'm having Memory Limit Exceeded, on the implementation I did, while editorial says the same.

51582194

Thanks, in advance.

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

How should I approach Problem D in Java? I m not able to get the structure of code for this problem in java.

  • »
    »
    5 лет назад, # ^ |
    Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

    Not sure if you're still looking for a response, but my approach was as follows: Use ArrayDeques for each letter or '?' to store the indices. Then, when matching letters I just polled left and right until either went empty and then matched rest with '?' if I had any '?' remaining. In the meantime, you can track how many pairs you have created and use StringBuilder's insert method to put that at the front of the output. Code: https://codeforces.com/contest/1141/submission/51599198

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

For problem "Same Sum Blocks (Hard)" for finding all the possible sum if I do the loop like this

map<ll,vector <pair<ll,ll>> > mymap;
    for(int i=0;i<n;i++){
		 ll tsum=0;
		for(int j=i;j<n;j++){
			tsum+=vec[j];
			mymap[tsum].push_back({i,j});
		}
    }

then I'm trying to find the maximum number of disjoint set but it doesn't give me the optimal answer as you can see here 51596165 can anyone explain why it isn't working?

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

Is there an intended slower solution that was meant to pass F1 but not F2 ?

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

    Sure. I did the following. The idea is much more standard but might be trickier to implement if you lack experience at dp. Find all different sums of the segments. Now for each one you can do $$$dp[i]$$$ — the maximal number of disjoint segments of this sum up to position $$$i$$$. Updates can be done straightforwardly by iterating over all $$$j < i$$$ and checking if the sum between $$$j$$$ and $$$i$$$ is the current one or not. That's $$$O(n^4)$$$ at best ($$$O(n^5)$$$ if no prefix sums). 51606155

    Btw you can also AC f2 if you do updates in $$$O(1)$$$ instead of $$$O(n)$$$ lol. That would be $$$O(n^3)$$$. 51606140

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

      Why your $$$O(n^3)$$$ solution passes. :xD. Isn't $$$n=1500$$$ too much for $$$n^3$$$.

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

        Welp, I just believed that there are not that many distinct sums such that each of them appear at least twice) Apparently, the number is less than expected $$$O(n^2)$$$. I'd be glad to hear the countertest)

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

      Hi Mike,

      Thanks for your reply. I appreciate you taking the time to explain your solutions. :)

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

      Isn't the dp part just like finding the LIS?

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

1141A - Game 23 can be also solved using dfs.

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

For problem G I thought of first painting the k vertices which have maximum number of neighbors i.e. to paint the k maximum neighbor vertices with color 1 and then paint rest of the vertices. The number of colors required would be then the maximum number of neighbors of remaining n-k vertices. I don't know how to implement this also whether this approach is correct or not.Has someone else followed this strategy.

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

    hello .......

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

      you can find the (k+1)th largest degree let's say 'd' and this is the maximum number of color needed to color the graph. Now, you can use DFS to color the edges by initiating some variable let's say 'c' with some integer in between 0 to d-1(assuming 0 indexed color) and each time when you move to unvisited vertex make c = (c + 1)%d.

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

Anyone else having problem with problem G test 24 ?

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

In code of 1141G — Privatization of Roads in Treeland why was it necessary to set f=-1 after color and f became equal?

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

Can someone explain me what went wrong in this (my solution for problem E)

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

In problem G for (auto p: cnt) if (kk > k) D = p.first, kk -= p.second; else break; how we get that D we get from the above loop is the minimum

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

Interesting problems, thanks.

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Binary Search Solution for problem G Simple solution

»
16 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

"vector<pair<int,int»"