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

Автор shishyando, 23 месяца назад, перевод, По-русски

Мы, конечно же, знаем о том, что много решений не прошли системное тестирование, и нам правда жаль, что так вышло. Тем не менее, мы надеемся, что вам всё равно понравились сами задачи.

A: Много цифр
B: Z mod X = C
C: Перестановка столбцов
D: Ловушка
E: MEX против DIFF
F: Разнообразные отрезки
G: Алгоритм Люсине
H: Сложный разрез
Разбор задач Codeforces Round 792 (Div. 1 + Div. 2)
  • Проголосовать: нравится
  • -206
  • Проголосовать: не нравится

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

Weak pretest C...

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

Good F though i didn't solve it in time:)

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

very good round! especially pretest for C! THANK YOU!!!!!!!!!!!!

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

    pretest for D are also very good!!!!!! the best round of this year

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

    Did you prove your solution?

    • »
      »
      »
      23 месяца назад, # ^ |
        Проголосовать: нравится -54 Проголосовать: не нравится

      i don't have time to prove my solutions on the contest. it's better to get a WA than lose a lot of time

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

        then it's your problem that your solition failed system testing, not authors. if we did have very very strong pretests, some problems could be solved by just guessing the solution which is bad for me

        • »
          »
          »
          »
          »
          23 месяца назад, # ^ |
          Rev. 2   Проголосовать: нравится +10 Проголосовать: не нравится

          well, if someone tries to guess the solutions, he gets a huge penalty. Also it's possible to guess the answer only in div2 A, so the pretest for other tasks should be strong

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

            ok, your opinion is not bad too, but that's codeforces and if your solution passed pretests, it doesn't mean that it will past system testing

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

      I proved my solution and it worked as charm if elements were distinct, I didn't consider when elements are equal.

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится -33 Проголосовать: не нравится

    very good round! especially pretest for C! THANK YOU!!!!!!!!!!!!

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +31 Проголосовать: не нравится

Passed pretests for C, but failed in system test. Please make the pretests stronger

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

for C, how can we load so many elements into a matrix if the size of the matrix is 10 ^ 5 x 10 ^ 5 ??

  • »
    »
    23 месяца назад, # ^ |
    Rev. 2   Проголосовать: нравится +21 Проголосовать: не нравится

    It's guaranteed that the sum of n*m over all test cases does not exceed 2*(10^5).

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

    It does say that the sum of $$$n \times m$$$ is less or equal to $$$2\times 10^5$$$

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

    In the statement it says that $$$n \cdot m \leq 2 \text{e}5$$$. So the total number of matrix entries is at most $$$200 000$$$.

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

    The size of the matrix is not 10^10 it is 10^5 , you can read the constraints again, so the entire matrix has 10^5 elements in total . so ya this number is doable . Happens.

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

I got WA on test 12 in C, and so many people also getting this, can anybody tell me why this happened? Thank You :)

  • »
    »
    23 месяца назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    This test case will give -1 for all(mostly) those who got WA

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

    if you found anywhere that previous element in column is greater than next one then you have to check totally left and totally right untill you didn't get their exact position and then store them like this 1 4 3 3 3 3 or this 1 4 4 4 4 3 .

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

Can somebody mention test case 12 of problem C?

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

Please add tutorials for other problems too!

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

downvote

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

very good c pretest, very challenging pretest, LOVE IT

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

I solved problem D without realising the fact that we should always use all $$$k$$$ jumps, here is my approach:

Let $$$b_i$$$ denote the reduction in the damage you can get by jumping over the $$$i$$$-th mine. Initially, $$$b_i = a_i - (n - i)$$$ as the $$$n - i$$$ mines after $$$i$$$ each gain an extra point of damage.

Now notice how the array $$$b$$$ changes after we jump over a mine, say at position $$$j$$$. For $$$i<j$$$, $$$b_i$$$ would increase by $$$1$$$ as there is one less mine affected by the additional damage. For $$$i>j$$$, $$$b_i$$$ would also increase by $$$1$$$ as the additional damage from jumping over $$$j$$$ can be skipped as well.

Therefore we can show that the relative ordering of values in $$$b$$$ never changes, and we can do a simple greedy, taking the maximum $$$b_i$$$ each step.

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

I set the condition for 3 incorrect positions in C, but there was WA 2 xd, I had to remove it and got OK/ 157699542 and 157709794 UPD i do not check other data in test :((

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

Problem G's tests were not very good: 157719356

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

Great round, why do you downvote??? I understand that this round has weak pretests, but problems weren't bad

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

$$$Concise$$$ tasks! The main thing was the idea, not the knowledge of a well-known complex algorithm.

P.S. I almost solved D using logic as in editorial, but also used a segment tree for.. who knows. Got WA. Removed segment tree — got AC :D (Always important to prove solution first)

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

Tell me please where I am wrong In A if we have a 3 digits number like 312, the answer should be 2, because there is no way that Alice can play, so that she gets 1. What is wrong with that logic?

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

    swap (3, 2) -> 21 -> swap(2, 1) -> 1

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

    Logic for $$$n > 3$$$: move mimimum digit to $$$2nd$$$ position and don't touch until last Alice step. Then swap with $$$1st$$$ and done.

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

is there any idea for solving D using binary search ?

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

    No, it could make sense if not all of $$$k$$$ jumps could be used for some reason, but here it is proved that we should use all of them, so solution is greedy.

»
23 месяца назад, # |
Rev. 3   Проголосовать: нравится -59 Проголосовать: не нравится

Maybe some of the problems are one of the best in 2022 (as one of the testers said). But problem C is one of the worst this year (problem on its own + pretests). So sad pretests were bad for this round.

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

The worst pretests EVER.

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

Some hacks in problem E returning unexpected verdict?

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

How to fix WA5 in F? My solution

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

Still couldn't understand problem D . I got the part why we need to use all k jumps but why pickih the k maximal values of ai — (n — i) would work ? Can someone explain .

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

nice, great, awesome, incredible, unbelievable, insane, amazing, astounding, astonishing pretests for C.

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

Weak pretest C... Many top coders did mistakes in a hurry but at least that test case should be in the pretest. 1 FST can ruin a full contest.

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

Can somebody write the editorial on "How to understand this editorial !!"

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

In addition to weak pretests in C and D, it is also bad TESTS in G. Look at this submission. This is the most simple greedy solution, which should not pass the test, but it did.

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

This is my approach for problem D - Let's say you can jump only once. Then our main aim is to find the index jumping over which gives us minimum total damage. Consider two indices i, j such that i < j. If we see, either we jump at element at index i or index j, it will add same answer (n — j) to subarray [j+1, n]. So, main concern is subarray [i, j]. Now, if we remove i, then total damage for this subarray will be a[i+1] + a[i+2] ...... + a[j] + (j — i). If we remove j , then total damage for subarray [i, j] = a[i] + a[i+1] + ..... + a[j-1].

On subtracting first equation from second we get a[i] — a[j] — (j — i). So, if it's better to remove j in optimal solution then above written expression should be less than equal to 0 i.e. a[i] — a[j] — (j — i) <= 0 which implies a[i] + i <= a[j] + j. So, here we seen for two indices. Similarly can be proved for other indices as well. So, sort given elements according to a[i] + i and jump over maximum k elements sorted according to a[i] + i.

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

    idk but unfortunately it's bad to use conditional like this

    else if(ind.size() > 2){ cout<<-1<<endl; return; } ( u already check in !is_sorted ) or swap in this task. I had the same problem

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

    When you return if m == 1, you do not read some a values, and next iteration of solver reads them instead of new n and m.

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

Weak pretests in C? That might be happened sometimes. The biggest problem is, if someone did not hacked main test 77 in problem D, many wrong solutions might get AC (and unwarranting scores).

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

In E there is the following funny solution — note that it is always advantageous to make such a change in which the mex increases. So, to find out the final mex, you can simply do a binary search.

And if we know the final mex, then we must delete all the elements of the not less mex in order of increasing the number of occurrences in the array.

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

    You can find the final MEX without using binary search. Just try to fill in the holes starting from 0 and stop when the number of holes gets higher than k. (Submission)

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

    Hey, Have you read the editorial of task $$$E$$$.

    If yes? In the author's implementation, in the current iteration wherein we are assuming the $$$mex$$$ to be $$$i$$$, where do we ensure that $$$i$$$ is not present in the set $$$s2$$$? I mean, where do we ensure that $$$i$$$ is surely getting picked up and replaced with some other non-negative integer. If $$$i$$$ is not removed, then the $$$mex$$$ is definitely not $$$i$$$, won't it affect the final $$$ans$$$?

    • »
      »
      »
      23 месяца назад, # ^ |
      Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

      For first, i write this before editorial, for second, you can no tnihg in this solution and implementation it turns out to be very simple without places where you can make a mistake)

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

      I guess we cannot ensure i is not in s2. But this will not affect the answer: if mex is something larger, then currently we over-estimated the cost and later when we enumerate to the actual value of mex we will get the corresponding true cost.

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

Weak pretest in B -_-

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

I think that pretest is made to not make a load of testing when the round is running... so the pretests must be so strong, so when someone get pretests passed, his probability to get accept should be 95% or above, because when I got WA on pretests I could modify my code and submit it again and got accepted, but after the round has finished and got WA or TLE in the tests after pretests I can't do anything in that time....

So the pretest should contains all tricky tests and corner tests and TLE tests.

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

Since there is no editorial for problem E could somebody give me a brief explanation of his idea please?

Contest was great, one of the most enjoyable for me. Weak pretests ≠ bad contest.

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

In Editorial for problem A maximum is written instead of minimum

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

Good problems but weak pretests. Oh well...

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

There is a person who is inexplicably similar to my code. I think it may be that someone in my room maliciously distributed my code. Unfortunately, I have no evidence

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

too much weak pretest for problem C ;)

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

My solution ideas for E, G, since there is no tutorial for E and G, yet.

Problem E
Problem G

E Code

G Code

(Sorry for not including formal proofs and latex, i find it easier to understand and explain intuitions)

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

    For E: "and we do not care about any element >= m." Don't we also need to make sure that m should not be present for mex to be m? edit: is the reason that we can ignore this, the fact that, let's say when we fix mex = m, the actual mex was m+5, then we will get a strictly better answer when we fix the actual mex to be m+5?

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

      Yes! Because, higher the MEX, better the answer would be, I also had the same confusion but it doesn't matter whether you remove elements equal to m or not.

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

The solution for E is different from mine, I used binary search (once again XD)

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

I'm just counting with inspect element, but in the top 2000 competitors, I ended up with 559 FSTs, a failure rate of 28%. Compare that with the last Div. 1 + 2 round, where I got 91 FSTs, or 4.5%, or the one before that with 76 FSTs, or ~4%. That's pretty absurd.

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

Secondly, let's say that we immediately get n−i damage if we jump over i-th trap. This way the first trap that we jump over will cause k−1 damage more than it should (because of k−1 traps that we jump over next), the second will cause k−2 damage more, ..., the last one will cause 0 damage more. So the total damage only increases by k(k−1)2 which does not depend on the traps that we choose. That's why the traps that we have to jump over in this problem are the same.

Can someone please explain what the author is trying to say here. I don't get how we get k-1 more damage if we do 1st jump, shouldn't it be n-i-(k-1). and similarly for 2nd jump n-i2-(k-2) and so on.

Edit: Figured it out.

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится +17 Проголосовать: не нравится

My take on D.

We have to make K jumps, suppose we make them at indices (i1 , i2 , i3 .... ik) [0-indexed].

  1. First Jump will save us --> ( a[i1]-(n-i1-1)+(k-1) )dmg --> (a[i1] + i1 + constant1)
  2. Second Jump will save us --> ( a[i2]-(n-i2-1)+(k-2) )dmg --> (a[i2] + i2 + constant2)
  3. Kth Jump will save us --> ( a[ik]-(n-ik-1)+(0) )dmg --> (a[ik] + ik + constantk)

We see that the jumps will be more beneficial for us if we do them on traps which have higher a[i] + i value, as they give us better minimization of dmg. Thus the greedy approach :).

Edit:

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

    isn't this possible that for some trap we might get a (save on damage) negative and then we should simply not jump that trap right so , why always do k jumps

    jumping on a trap with negative (damage save) would be increasing damage.

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

In task B,I didn't read the statement correctly and took it as $$$ a < b < c \le 10^{18}$$$.

Is this task solvable then?

  • »
    »
    23 месяца назад, # ^ |
      Проголосовать: нравится -13 Проголосовать: не нравится

    Have you read the intended solution? Why wouldn't it be solvable?

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

      I mean that I wonder if it's solvable when $$$a<b<c \le 10^{18}$$$,bacause we have a limit of $$$x,y,z \le 10^{18}$$$.

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

    Yes, it is. Try this, $$$x=a+b+c, y=b+c, z = c$$$

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

      Nope, it is not. X must be greater than C and also fit in condition <= 10^18. It would not work for C=10^18

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

        I developed a way to solve the task when $$$a<b<c\le10^{18}$$$ and $$$x,y,z \le 2 \times 10^{18}$$$.

        And I'm curious if we can make the constraints a little smaller.

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

Anyone can explain F? I can’t get the idea from editorial. I tried to compute the shortest second occurrence of the same number for L and R, but not sure how to get minimum range.

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

I don't know a good place to say this or not but the 'You have to to do the following operation exactly once' should have been in bold letters in problem C.

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

H can be solved with dfs.

157757076

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

Can someone please help me understand why my solution for D is failing.

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

In D how is jumping over the first trap causing $$$k - 1 $$$ shouldn't it be $$$ n - 1 $$$? The first line of the second paragraph is literally that.

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

Not a very good way to give an editorial!

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

    What's the problem with editorial?

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

      I preferred the editorials better when there were hints given you know, those are great during up solving a contest. well everyone has their own taste so.

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

For D, I thought that it would be a good idea to check for all jumps $$$0 \leq x \leq k$$$ the minimal value of damage taken; since the problem said "no more than k jumps".

Let $$$sum = \sum_j a_j$$$ .

For 1 jump, the total damage taken is $$$sum + (n-k) - a_k$$$ where $$$k$$$ is the index that we jump over. $$$n-k$$$ is the bonus damage we will get from all further traps after $$$k$$$.

For 2 jumps, the total damage taken is $$$sum+(n-k_1-1)+(n-k_2)-(a_{k_1}+a_{k_2})$$$ where $$$k_i$$$ is the index of the $$$i^{th}$$$ jump. Note that $$$-1$$$ with $$$n-k_1$$$ is due to the fact that we jump over $$$k_2$$$ as well and so no bonus damage taken there. (I initially forgot this part and got a WA).

Generalising, for $$$x$$$ jumps, the total damage taken is $$$sum+x*n- \frac{x(x-1)}{2} - [{\sum^x_{i=1}} (a_{k_i} + k_i)]$$$. Here for calculating the $$$[{\sum^x_{i=1}} (a_{k_i} + k_i)]$$$ part, we sum $$$a_i + i$$$ for every $$$i$$$ and store it in a separate array (say b), and then pick the max $$$x$$$ elements from the array greedily. So on each increasing value of $$$x$$$, we subtract the $$$b[n-x]$$$ value and recalculate the damage the this stage.

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

    I tried to understand official editorial for 2 days. Yours I understood instantly, thank you sir.

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

https://codeforces.com/contest/1684/submission/157771378 i have checked so many cases but still not able to find the mistake please can anyone help in finding the mistake in this or which case i am missing

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

In editorial of D, it is said that we must choose k maximal values. But if a[i] — (n-i) happens to be negative (but still coming in k maximal), why to take it. It will increase the cost rather than saving.

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

    Notice that first value to remove can never be negative(you can always remove last element in A without penalty), also notice that removing ANY element from A(and related value from B) is increasing left values in B by 1(values from left in A do not add extra penalty 1 for already removed element from right, values from right in A increase their value by 1 from already removed element from left)

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

how to handle the case when we use less than k jumps in problem d; cause in editorial we always consider k jumps exactly

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

    Its always optimal to use all the k jumps. Reason for this is clearly mentioned in editorial:
    it is always better to use all k jumps. If we jumped over less than k traps then we can jump over the last trap and the total damage will be less
    Try reading it properly.

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

nice editorial explanation

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

Can anyone help me understand the solution for problem F in the editorial?

I have understood the entire logic, but facing some problems with the part where we have to calculate j. The editorial says the following:

This j could be found, for example, by binary search in cnt array. To check whether two elements are in the same segments it is possible to use a segment tree or a Fenwick tree. It is possible to store for each i such maximal rj that there is a given segment [lj,rj] and lj≤i.

I am not sure what is cnt array and how we are using segment trees here.

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

Minor nitpick: Editorial of A says: "Let $$$k$$$ be the length of $$$n$$$, [...] $$$k=1$$$ [...]" — but $$$n \geq 10$$$ according to the input constraints, so there is no case with $$$k=1$$$.

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

I passed B in 1.5 hours, hooray

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

What is meant by "FST"?

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

Does maximizing MEX (in problem E) always yield to the best answer? If it does, how to prove it?

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

    Hint: diff — mex = count of unique numbers after mex

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

    If you change a number to increase the MEX it will either won't change the answer or increase it, but never decrease it. So, maximing the MEX is a greedy choice

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

I solved D in the contest with that idea but I still feel something not correct, "we immediately get n−i damage if we jump over i-th trap" but I think it only correct if that is the last jump.. Sr for my bad english, hope you still able to understand what i mean

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

https://codeforces.com/contest/1684/submission/157771378 i have checked so many cases but still not able to find the mistake please can anyone help in finding the mistake in this or which case i am missing

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

"This way she can always get the maximal digit of n in the end of the game." maximal -> minimal

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

Why my C got WA on test 13: 157808169

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

Problem : 1684C

shishyando i think there is weak test case. case:

1

2 6

10 20 50 30 60 100

1 1 1 1 1 1

Correct ans : 3 4

please check this solution 157739326, get -1 but accepted.

Please also check the almost same two codes( 157871675 , 157866257 ). One is accepted, another is Wrong answer there is no solution.

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

In problem H there is an easier solution for $$$K>5$$$.

Just cut the number into single digits, and from left to right concatenate a number with the next digit, if the total sum does not exceed the next power of 2. I don't have proof, but probably it is just some case analysis.

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

    If you think about this approach during the contest, how to realize that this approach is wrong when only sum=5?It is too difficult for me.

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

      I upsolved the problem after the editorial. Also I did not know about the $$$K=5$$$ corner case: 111101 -> 11-11-01 is 7 with my construction.

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

Is there a way to come up with solution for problems like problem B. I solved it with Guessing.

  • »
    »
    23 месяца назад, # ^ |
    Rev. 3   Проголосовать: нравится +19 Проголосовать: не нравится
    $$$ x \bmod y \equiv a $$$
    $$$ y \bmod z \equiv b $$$
    $$$ z \bmod x \equiv c $$$

    Let's try to reduce our possible solutions, by assuming that $$$x > z$$$, which leads us to $$$z = c$$$ using the third expression. You could try and play with $$$x < z$$$, but it wouldn't help much. Also, $$$z = c$$$ only works because $$$b < c$$$, as $$$z$$$ needs to be greater than $$$b$$$ on the second expression.

    Assuming that $$$z = c$$$, we are left with only two expressions:

    $$$ x \bmod y \equiv a $$$
    $$$ y \bmod c \equiv b $$$

    Using equivalent expressions:

    $$$ x = a + k_1 y $$$
    $$$ y = b + k_2 c $$$

    Applying the second expression on the first:

    $$$ x = a + k_1(b + k_2 c) $$$
    $$$ x = a + k_1 b + k_1 k_2 c $$$

    Now we need to find $$$k_1$$$ and $$$k_2$$$ that satisfies our initial assumption $$$x > z$$$, the simplest and most direct guess, which also leads to the editorial's solution: $$$k_1 = k_2 = 1$$$

    $$$ x = a + b + c $$$
    $$$ y = b + c $$$
    $$$ z = c $$$

    Also, this only works because $$$a < b$$$, as $$$b+c$$$ needs to be greater than $$$a$$$ in the first expression.

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

If you are/were getting a WA/RE verdict on problems from this contest, you can get the smallest possible counter example for your submission on cfstress.com. To do that, click on the relevant problem's link below, add your submission ID, and edit the table (or edit compressed parameters) to increase/decrease the constraints.

If you are not able to find a counter example even after changing the parameters, reply to this thread (only till the next 7 days), with links to your submission and ticket(s).

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

For E can anybody give a real proof for why maximizing MEX is always the best?

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

    Does anyone know WHY I got so many downvotes? I have seen similar insane and meaningless downvotes elsewhere on Codeforces so I already know this crazy atmosphere. But this is wrong. Stop doing your meaningless downvotes and in particular, downvoting my comments doesn’t increase your rating.

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

Ugly implementation problems

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

I implemented a DP approach in D... but ended up getting WA on test 2. Can DP not solve D? and why?

here is my submission link -> https://codeforces.com/contest/1684/submission/248797672