shishyando's blog

By shishyando, 22 months ago, In English

We know about FST and we are really, really sorry about it. Even though we still hope that you liked the problems.

A: Digit Minimization
B: Z mod X = C
C: Column Swapping
D: Traps
E: MEX vs DIFF
F: Diverse Segments
G: Euclid Guess
H: Hard Cut
  • Vote: I like it
  • -206
  • Vote: I do not like it

| Write comment?
»
22 months ago, # |
  Vote: I like it +229 Vote: I do not like it

Weak pretest C...

»
22 months ago, # |
  Vote: I like it +13 Vote: I do not like it

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

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

    Neither did I.qwq

    But really like the problems like F.

»
22 months ago, # |
  Vote: I like it +167 Vote: I do not like it

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

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

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Did you prove your solution?

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it -54 Vote: I do not like it

      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

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

        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

        • »
          »
          »
          »
          »
          22 months ago, # ^ |
          Rev. 2   Vote: I like it +10 Vote: I do not like it

          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

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

            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

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it -33 Vote: I do not like it

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

»
22 months ago, # |
Rev. 2   Vote: I like it +31 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
    Rev. 2   Vote: I like it +21 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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$$$.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

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

    • 1 3
    • 2 2 1
  • »
    »
    22 months ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    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 .

»
22 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Can somebody mention test case 12 of problem C?

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Please add tutorials for other problems too!

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

downvote

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

very good c pretest, very challenging pretest, LOVE IT

»
22 months ago, # |
  Vote: I like it +57 Vote: I do not like it

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.

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

    damn, i had that idea, but i thought that I should only do that when a_i — (n — i) > 0

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    used the same approach

»
22 months ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it +39 Vote: I do not like it

Problem G's tests were not very good: 157719356

»
22 months ago, # |
  Vote: I like it +52 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    Is there a distinct border between "weak pretests" and intention to increase hacks amount?

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

    I guess people are salty after getting FST's.

»
22 months ago, # |
  Vote: I like it +13 Vote: I do not like it

$$$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)

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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?

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

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

is there any idea for solving D using binary search ?

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
22 months ago, # |
Rev. 3   Vote: I like it -59 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it -17 Vote: I do not like it

The worst pretests EVER.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Some hacks in problem E returning unexpected verdict?

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to fix WA5 in F? My solution

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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 .

»
22 months ago, # |
  Vote: I like it -10 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it -10 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it +19 Vote: I do not like it

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.

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

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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it
  • »
    »
    22 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

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

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).

»
22 months ago, # |
  Vote: I like it +36 Vote: I do not like it

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.

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

    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)

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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$$$?

    • »
      »
      »
      22 months ago, # ^ |
      Rev. 2   Vote: I like it +8 Vote: I do not like it

      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)

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Weak pretest in B -_-

»
22 months ago, # |
  Vote: I like it +5 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

In Editorial for problem A maximum is written instead of minimum

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Good problems but weak pretests. Oh well...

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

too much weak pretest for problem C ;)

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it
»
22 months ago, # |
Rev. 3   Vote: I like it +38 Vote: I do not like it

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)

  • »
    »
    22 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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?

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

»
22 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

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.

»
22 months ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

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
  • »
    »
    22 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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.

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    22 months ago, # ^ |
      Vote: I like it -13 Vote: I do not like it

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

    • »
      »
      »
      22 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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}$$$.

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

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

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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

      • »
        »
        »
        »
        22 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.

»
22 months ago, # |
  Vote: I like it +3 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it +19 Vote: I do not like it

H can be solved with dfs.

157757076

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it +3 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Not a very good way to give an editorial!

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What's the problem with editorial?

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

      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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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
  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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)

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

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

    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.

»
22 months ago, # |
  Vote: I like it +3 Vote: I do not like it

nice editorial explanation

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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$$$.

»
22 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I passed B in 1.5 hours, hooray

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

What is meant by "FST"?

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

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

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Why my C got WA on test 13: 157808169

»
22 months ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

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.

»
22 months ago, # |
  Vote: I like it +26 Vote: I do not like it

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.

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

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

      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.

»
22 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
    Rev. 3   Vote: I like it +19 Vote: I do not like it
    $$$ 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.

»
22 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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).

»
22 months ago, # |
  Vote: I like it -10 Vote: I do not like it

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

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
22 months ago, # |
  Vote: I like it -10 Vote: I do not like it

Ugly implementation problems

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it
»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

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