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

Автор satyam343, 3 месяца назад, По-английски

Thank you for your participation! I hope you liked atleast one problem from the set (:

1930A - Максимизируйте счет

Idea: satyam343
Editorial: Non-origination

Hint 1
Solution
Code

video editorial by aryanc403

1930B - Печать перестановки

Idea: satyam343
Editorial: satyam343

Hint 1
Solution
Code

video editorial by aryanc403

1930C - Лексикографически наибольший

Idea: satyam343
Editorial: Non-origination and satyam343

Hint 1
Solution
Code

video editorial by aryanc403

1930D1 - Сумма по всем подстрокам (простая версия)

Idea: satyam343
Editorial: satyam343

Hint 1
Hint 2
Solution
Code

1930D2 - Сумма по всем подстрокам (сложная версия)

Idea: satyam343
Editorial: satyam343

Hint 1
Solution
Code

1930E - 2...3...4.... Замечательно! Замечательно!

Idea: satyam343
Editorial: satyam343

Hint 1
Hint 2
Solution
Code

1930F - Максимизируйте разницу

Idea: satyam343
Editorial: satyam343

Hint 1
Hint 2
Solution
Code

1930G - Подсчет множества префиксных максимумов

Idea: satyam343
Editorial: satyam343

Hint 1
Hint 2
Hint 3
Solution
Code

1930H - Интерактивное дерево мексов

Idea: satyam343
Editorial: satyam343

Hint 1
Hint 2
Hint 3
Solution
Code

1930I - Считать всегда весело

Idea: satyam343
Full Solution: Elegia
Editorial: errorgorn

Hint 1
Solution
Code(errorgorn)
Разбор задач think-cell Round 1
  • Проголосовать: нравится
  • +151
  • Проголосовать: не нравится

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

My solution to problem C is very brief, maybe it could help: https://codeforces.com/contest/1930/submission/246846484

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

    Can you please explain, How it works ?

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

      Think about the simplest situation: select numbers from the end of the array to the front. This can ensure that the resulting S is the lexicographically largest but not necessarily the longest because some elements might be repeated. It can be proven that you can always, in some ways, reduce those repeated elements to the ones that haven't appeared in the set. You can do the reduction through a simple iteration through the sorted array b: since the element after must be smaller than the element front, b[i]=min(b[i],b[i-1]-1), which can ensure all elements appear at most once and are lexicographically largest.

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

    I did the same thing. Don't know why they are using upper_bound to find largest element everytime when the sequence can be found beforehand.

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

      when I did this problem, I also first came up with using upper_bound, but I felt it was too complicated for me so I came up with this way

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

Nice contest!

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

I believe my solution for C is slightly different from the editorial, and imo cleaner.

Let $$$b_i = a_i + i$$$

Now the claim is that if all the elements of $$$b$$$ are distinct, then the descending order of $$$b$$$ is the answer. Try to prove why this might be the case yourself, its not hard. I'd recommend taking some examples and trying to figure it out. ;)

The other case to handle is when there are duplicates.

Let the value $$$x$$$ repeat at least twice in $$$b$$$. Then we can always make the values $$$x$$$ and $$$x - 1$$$ instead of $$$x$$$ and $$$x$$$.

How?

We may now repeat the above operation multiple times until all the elements of $$$b$$$ are distinct.

These observations are enough to solve the problem.

Here is my code: 246841577

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

    Well, I thought of a similar logic & proof while contest time, but I wasn't fully convinced. Looking at your proof, to me it feels like your logic is a bit incomplete. It's obvious that if x appears n times in {y | y = ai + i}, then x, x — 1, ... , x — (n — 1) can be made. But is it really possible to make x, x — 1, ..., x — (n — 1) while not influencing other numbers? (i.e. let's say array a is {5, 4, 2} and if you take a[0] first, the result would be {6, 5, 3} but answer would be {6, 5, 4}.) So basically, my question is "is it guaranteed that such sequence of operation exists? how can you prove it?"

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

    The point is, I'm worried about the case where your logic "Then to construct the values x and x−1 we can first delete the index i, resulting in x, and then we can delete index j resulting in the value x−1." influencing other indexs such that ai + i == x does not hold. Maybe it's just obvious and I'm just being dumb, but I thought about this for 2 hours but couldn't prove it. So if someone can prove this, I would be really greatful. Thanks in advance.

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

      Hmmm... You're right about my proof being incomplete, and actually maybe incorrect as well.

      for instance my proof idea would be incorrect for the following example -

      1
      4
      100 2 3 97
      

      And while the answer is 101 100 6 4, its not because of the reason I mentioned. Its because you first delete index 3, then 4, then 2 and finally 1.

      So indeed my proof is incorrect, thanks for pointing it out!

      But now that I think about it, our goal is to only reduce the value of index $$$j$$$ by one, and it doesn't matter how exactly we do it.

      So in order to reduce the value of index $$$j$$$, let us look at index $$$j - 1$$$. If we do not wish to reduce index $$$j - 1$$$ by any value, then we can simply delete it and we managed to reduce the value of index $$$j$$$ by 1. However, if we wanted to decrease $$$j - 1$$$ as well, then we look at $$$j - 2$$$ and so on. If this keeps on happening, then eventually we will hit index $$$i$$$ which by definition we do not wish to decrease. Therefore we can delete index $$$i$$$ and the process stops. This way we have decreased the value of index $$$j$$$ without impacting any of the other numbers in between (since the in between numbers had to be decreased as well)

      I hope I didn't mess up anything this time. Incase I did, kindly correct me once again :P

      EDIT: Another thing that I forgot to mention is that we will start decreasing the value starting from the right-most element. If it is already at the required value, then we can simply delete it. Otherwise we do the process mentioned above. This ensures that the deletion process doesn't impact any numbers after index $$$j$$$.

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

        I'm still not convinced. Let's call the value we want a result want[0], ..., want[n — 1]. In order your logic to work, I think you should also prove that for every i, 0 <= a[i] + i — want[i] <= i. i.e. is it possible to prove that the difference between ai + i and want[i] is not bigger than i? if this is proved, i think the claim is quite obvious.

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

          I'll use the terminology I used above, ie. $$$b_i = a_i + i$$$

          The claim is that $$$want[i] >= b_i - (i - 1)$$$, ie. I'll decrease $$$b_i$$$ by $$$i - 1$$$ times at most before deleting it. (Also note that we can't decrease $$$b_i$$$ by more than $$$i - 1$$$ since there are only $$$i - 1$$$ elements before it)

          And since there are at most $$$i - 1$$$ distinct values before $$$b_i$$$, whereas the number of options for the $$$i^{th}$$$ value is $$$i$$$ (since we can decrease by $$$0, 1, 2, ..., i -1$$$) we can always find a suitable $$$want[i]$$$ such that $$$want[i] >= b_i - (i - 1)$$$

          This should prove what you're asking for.

          I've rarely written proofs so I really apologise for not being thorough in my proof,

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

      I was also worried about the same thing and it turns out that there is always a way to preserve other elements while decreasing duplicate elements but I don't know how to prove this claim.

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

    In the contest I ended of solving C with dynamic fenwick tree(?) which can answer k'th none existing integer in O(log^2(n)). O(logn) is also possible with DST, but I really didn't want to implement DST so I went for dynamic fenwick tree. My solution is O(nlog^2(n)) and it almost got TLE. For those who are interested (although I'm certain no one will be. just look at the struct fwtree part) -> https://codeforces.com/contest/1930/submission/246865035

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

      Can you please explain your code? Even I am unable to convince myself that the elements between 2 x's will remain unchanged

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

        you can approach this problem by greedy. if you think about it, a[0] can be a[0] + 1 ~ a[0] + 1, a[1] can be a[1] + 1 ~ a[1] + 2, ... a[n — 1] can be a[n — 1] + 1 ~ a[n — 1] + n now, we pick one numbers from each range. If there is a integer such that it is in the range a[i] + 1 ~ a[i] + i + 1, pick the biggest one. Greedy solution that chooses from small ranges (i = 0) to big ranges (i = n — 1) is correct, but I don't know why it is correct

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

      Can you explain how your fenwick tree is finding the kth non existing number. It would be great if you could provide any reference for this. Thanks

      ps:I am familiar with fenwick trees.

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

        It's similar to binary search. what we want is the maximum index i s.t. the # numbers before i (inclusive) is smaller than k. than i + 1 would be the kth number. If size of N = 1000: initialize res = -1. you first try 512 if # numbers before 511 (== # of numbers between [0, 511]) is less than k, you add 512 to res and subtract (== # of numbers between [0, 511]) from k. than you try 256, 128, 64, ... , 1.

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

    I was also thinking along the same lines that we should look at the first occurrence of maxiumum value in the array ai+i for every i . Then all the values after that will be subtracted by one . Then again we look for the first occurrence of maximum value and continue in the fashion. I thought of a variation in segment tree which gives the maximum and also updates the range. Can we do this question using this variation of segment tree as i haven't used this type yet. Ignore this i found the flaw in my logic

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

    I was aware of this solution. In fact, the model solution on polygon is exactly the same.

    I just included that particular solution in the editorial, as I found it easiest to explain, and it also uses a nice technique, which I liked.

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

A is similar to AGC001A

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

    Damn i dont know why my code is failing in second test case all I am doing is picking the minimum and adding it with the answer how can I spot that sorting is required here?

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

"Instead of counting strings s which are good, let us count the number of strings which are not bad."

Shouldn't this be, the number of strings which are bad?

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

How to prove that it is optimal to partition s into substrings of length 3 in problem D?

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

D is crazy

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

I could not even understand the problem statement for D problem , like how does it calculate the min no of 1s required in p-good string can someone explain?

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

Nice choice of title for problem E. The football match played 13 years ago was the last thing I was thinking about before this round :)

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

why iterator in problem c need --?

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

need help on 1930D1 - Sum over all Substrings (Easy Version), my submission 246919948

I'm really unsure where I lost, but clearly something wrong with calc

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

Can someone explain the editorial of C? i don't understand this "The elements at indices 1,2,…,x in the same order. The element at index k . The elements at indices x+1,…,k−1 in the same order." part.

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

    Hmm, yeah, this part looks strange... I suppose they mean the following. We have some order of deletion for array of length k. For the array of length k + 1, let's delete first k elements in the same order, but also delete k+1-st element after x deletions. Then we obtain the same good array, but with x appended to the end.

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

      Well, I suppose your explanation makes sense. so thank you. The editorial is so bad that it is almost impossible to understand.

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

Btw, in problem F there is a good way to think about efficient insertions of bitmasks. Consider the graph whose vertices are all possible bitmasks, and each bitmask is connected by directed edge with all submasks that can be obtained from it by switching one bit from 1 to 0. Then the sumbasks of a mask are just vertices reachable from this mask. So we can traverse this graph in order to find all submasks. And the pseudocode in the editorial is just dfs of this graph.

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

I will add the editorial of D and G after waking up.

Oh no, seems like he's fallen into a coma

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

E is really similar to https://codeforces.com/problemset/problem/1468/H. The hints mentioned in the editorial for E is exactly the solution to this problem.

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

    The setup of problem E is indeed the same as the problem you mentioned. It is indeed a coincidence.

    We still need to do the counting part, which a good amount of participants found non-trivial.

    Interestingly, our team participated in that round. My teammate solved that problem. But when I asked him to solve the problem E of my round, he didn't remember that gym problem.

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

Hello,

I received a notification regarding the similarity between my solution 246886924 to Problem 1930C and Yarab_Master/246865178to the same problem. While I acknowledge that our solutions may share similarities, it's important to clarify that we didn't exchange or share code intentionally. We're not acquainted, and we haven't communicated or shared solutions with each other.

I believe it's unfair to assume cheating solely based on similar approaches to problem-solving. Our solutions might align closely due to our thought processes or coding styles, but that doesn't imply rule violation.

I appreciate the efforts of the Codeforces team in implementing a system to detect potential plagiarism, but I would like to emphasize that in this case, it's a coincidence rather than deliberate copying.

I'm open to providing any additional information or clarification needed to address this matter. Thank you for organizing the round and presenting challenging problems.

Best regards, Vishal Sharma(vsvishalsharma777)

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

I still wait D solution -_-

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

For F I can't get the hints. Please can someone explain why the maximum difference will be find in that way:

  • For an array b consiting of m non-negative integers, f(b)=max(max(bi|bp)−min(bi|bp))

  • f(b) is the maximum value of bi ∧ ~ bj over all pairs

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

    Just fix , i and j. so all we want to pick is an x , which maximizes (b[i] | x) — (b[j] | x). Now look at a particular bit of b[i] and b[j]. There are 4 cases (1,1) ; (0,0) ; (1,0) and (0,1). (1,1) and (0,0) contributes nothing. In (1,0) take the corresponding bit of x as 0 and in (0,1) take corresponding bit of x as 1. From this you shall be able to deduce f(b) = b[i] ^ ~b[j]. Hope this helps. (Note that we dont need to prove "f(b)=max(max(bi|bp)−min(bi|bp))" ).

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

satyam343 please update the solutions.

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

satyam343 Hello? When will the solution be added?

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

satyam343 WHERE ARE SOLUTIONS???

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

Thank you for fast editorial

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

shit

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

am i the only one finding the editorial for E not understandable ?

"

Let us compress all the 0 's between the k -th 0 from the left and the k -th 0 from the right into a single 0 and call the new string t . Note that t will have exactly 2k−1 0 's. We can also observe that for each t , a unique s exists. This is only because we have already fixed the parameters n and k . Thus the number of bad s having exactly x 1 's is (x+2k−12k−1) as there are exactly (x+2k−12k−1) binary strings t having 2k−1 0 's and x 1 's."

its not necessary that in the string t we'll have exactly 2k — 1 0s

lets take this example 010100 and k is 1 if we compress the 0s inbetween the 1st zero from the left and the first zero from the right it'll become 01010 which has 3 zeros ?

also where did the x 1s come from ?? i really cant understand this tutorial

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

    ok after afew tries i realized that in order for the idea in the tutorial to work you also have to compress the k-th zero from the left and the k-th zero from the right into the compressed segment to form a string of length (2k — 1) zeros + (n — k*2 * L) ones and another thing u'll always need to keep that we dont have a solution when and only when there is no atleast one 1 in the segment between the k-th zero from the left and the k-th zero from the right

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

...