When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

MikeMirzayanov's blog

By MikeMirzayanov, 6 years ago, translation, In English

Hello!

ACM-ICPC Southern Subregional Contest (NEERC/Northern Eurasia) 2017 has ended on October 18. There were 73 teams onsite in Saratov, most of them were invited because of their result on the qualification stage.

On Saturday, October 21, 08:05 (UTC) will start online-mirror 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred).

I invite ACM-ICPC teams and individual participants of Codeforces competitions to take part! Sure, the contest will be unrated.

MikeMirzayanov

  • Vote: I like it
  • +122
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it +15 Vote: I do not like it

Great opportunity for preparation

»
6 years ago, # |
  Vote: I like it -126 Vote: I do not like it

Is it rated?

»
6 years ago, # |
  Vote: I like it -92 Vote: I do not like it

Is it rated?

»
6 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Will it be more Div1 or Div2 oriented? Asking this because last NEERC round was of Div2 difficulty.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

One computer for one team?

»
6 years ago, # |
  Vote: I like it +6 Vote: I do not like it

ACM-ICPC Rules,

Is it similar to normal codeforces competition for submission or different. In following terms -

  • Will there system cases apart from pretest.
  • And what's penalty rules.
»
6 years ago, # |
  Vote: I like it +13 Vote: I do not like it

Are you going to post editorial?

»
6 years ago, # |
  Vote: I like it +9 Vote: I do not like it

In C, I fixed the number of times I used the first package, and based on that calculated the minimum number of times I need to use the second package to satisfy the time constraint.
I got a lot of WAs on test 80 using this. But then I added a single line to swap the two packages if t2 < t1 and got AC.
I am unable to prove why always fixing the cheaper package is correct. Can someone please explain?

Also, how to solve B?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Hm, I came up with exactly the same colution and had WA89. After you suggestion I swaped packages if t2 < t1 and got AC in practice too...

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +15 Vote: I do not like it

    Basically in the optimal solution it's possible that you won't be using some package fully, because you will have already downloaded the file. Thus it's better to choose the slower of the 2 package types as the one you won't be using completely, that's why you need to swap or just do one swap in the beginning.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +23 Vote: I do not like it

    B: If graph has a cycle, answer is obviously -1. Otherwise, compute maximum possible for each vertex. Sort all vertices by that values. Go from smallest to largest, greedily select the minimum values which doesn't present yet.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Where can we find the onsite results?

»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

How to solve J? Was it greedy?

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +20 Vote: I do not like it

    We will always demolish a building as late as possible.
    For each building, find the highest month such that money for that month >= renovation cost of this building.
    Then go in inc order of months and destroy buildings greedily, i.e choose to destroy a building if it costs less than the money you have currently. Additionally, you may choose to "undestroy" a previously destroyed building in favour of a new cheaper building.

    See code for details.
    Code

»
6 years ago, # |
  Vote: I like it +54 Vote: I do not like it

Bitset works much better than FFT!

»
6 years ago, # |
Rev. 2   Vote: I like it +72 Vote: I do not like it

bitset works much better than fft rank 1

FFT works better than bitset rank 20

lol

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    It turns out that we are right lol.

»
6 years ago, # |
  Vote: I like it +2 Vote: I do not like it

When will the test cases be visible?

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

Why access to the solutions is restricted?

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve G and K?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    G:

    For min:

    Start from dfs from s. In the dfs (let the current vertex be u) if there is an adjacent undirected edge to v direct it like u <- v. Run dfs from the adjacent vertices.

    For max:

    Start from dfs from s. In the dfs (let the current vertex be u) if there is an adjacent undirected edge to v direct it like u -> v. Run dfs from the adjacent vertices.

    Code

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Sorry for the stupid question but how do you get the intuition that this greedy is optimal?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        For maximum:

        If we are in u and there is an unirected edge to v, there are two options:

        We go through this edge and we visit vertex v (we direct it like u -> v). This way we will increase our dfs tree.

        The other option is to direct the edge like u <- v. This way we will use this edge, only if we go to v from another path, and then visit u, but this won't increase the answer, as we have already visited u.

        From here we conclude that it's always best to direct edges like u -> v.

        For minimum:

        If we are in u and there is an unirected edge to v, there are again two options:

        We go through this edge and we visit vertex v (we direct it like u -> v). This way we will increase our dfs tree. Well we don't want to increase it.

        The other option is again to direct it like u <- v. Well this is optimal because this way we will actually reach only the vertices, reachable from s using the already directed edges.

        From here we conclude that it's always best to direct edges like u <- v.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you. Do you also know the solution for K?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +6 Vote: I do not like it

        it seems G is also solved by greedy algorithm. loop from left to right and then from right to left to make "s[i]<=s[pre]+1" sufficient. searching for explanations... 31557013

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        K:

        x[0] = s[0] + g[0]
        x[i] = min(x[i - 1] + 1, s[i] + g[i]), i = 1..n - 1

        y[n - 1] = s[n - 1] + g[n - 1]
        y[i] = min(y[i + 1] + 1, s[i] + g[i]), i = n - 2..0

        s'[i] = min(x[i], y[i])
        If s[i] ≤ s'[i] ≤ s[i] + g[i] for all i, then otherwise —  - 1

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Why is this correct?

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            I proved it by submitting and getting AC :)
            Actually we should find extremum(for minimum) points and simply make stairs between them. It looks like this: ./\./\./\./\.

»
6 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Is there any editorial available for this contest?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For question E i first took all the possible strings (indices) and then run a loop from 'a 'to 'z' including character only if it is not visited(not unfolded) and frequency of this character in all possible strings is equal to number of strings which means that it is occurring in every possible candidate of hidden string. Hence this character can be counted. But i could not use any data structure efficiently for this. Can someone please suggest some better one !!Thanks in advance :)

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For problem number H. When I want to copy case number 7 why it copied

45 f3409ufEFU1BQZKqdp2CV3QV5nUEsqSg1ygegLmqRygj

? :(

»
6 years ago, # |
  Vote: I like it +6 Vote: I do not like it

what is the idea of problem I ? and are there many ways to implement it ?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    It is pretty obvious that the array should be sorted first and then each partition will be a subarray of this sorted array. We do a binary search on the answer ans. To do so, we need to know whether we can divide the array such that each partition has size atleast k and the difference of each partition can be at most ans.

    We can solve this by dp. Let dp[i] be 1 if we can partition a[1...i] according to the stated condition. Now, consider the partition the ith element is in. The previous partition can end in at most the i - k th index. Also, consider the last element which is less than a[i] - ans. The current partition must start after that element. So, if any of the dp values within this range is 1, then we can set dp[i] = 1, otherwise it is zero. So, we need to check whether any of the dp values within a range is 1. We can easily do so by keeping a BIT on the dp values.

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

In question I after fixing the answer how to check wether this answer is possible or not?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I really enjoyed this one :) thanks you ^^

»
6 years ago, # |
  Vote: I like it +52 Vote: I do not like it

Why is it that solved problems in this contest do not appear as solved in the UI (that is with green coloring)? Every other contest is fine for me I think.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it -28 Vote: I do not like it

    Perhaps it may be because it is team contest.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +22 Vote: I do not like it

      I soloed the contest and only 2 of my solved problems are marked with green. It's probably a bug.

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        In my case I cannot see the problems I have solved in that contest, everything is just colored as white.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve B,my solution got WA and can not deal with all the situation TnT

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi, in Problem H, for the test "20 qqqoqqoqMoqMMMqqMMqM", my program outputs "4 MMMMM oqoqo qqMqq qqMqq ", and the result is "wrong answer Incorrect cut". I don't know why it is incorrect cut? Can anyone explain this?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Your program outputs "4 MMMMM MoooM qqoqq qqoqq" Which as you can see, reduces q count by 2, and increases o count by 2

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

How to solve D and L?

»
6 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Submission

How isn't "qqqqoqqqq" valid?!

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    You need to have as more palindroms as possible

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      determine the minimum number of palindromes of equal lengths to cut s into

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        ah, sorry, i read solution wrong

        your submission is wrong because you don't use all characters from given string