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

Привет, Codeforces!

В 20.10.2022 17:35 (Московское время) состоится Educational Codeforces Round 138 (Rated for Div. 2).

Продолжается серия образовательных раундов в рамках инициативы Harbour.Space University! Подробности о сотрудничестве Harbour.Space University и Codeforces можно прочитать в посте.

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Максим Neon Мещеряков. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

UPD: Разбор опубликован

  • Проголосовать: нравится
  • +178
  • Проголосовать: не нравится

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

Hope to cross 1100 <3

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

    Best of luck bro

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

    What F*ckhead created problem C ?

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

      What is wrong with this problem?

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

        Oh excuse me, absolutely nothing.

        Its just IMPLEMENTATION IS TERRIBLE

        If you don't have a specific idea, you gonna (-s-u-c-k-) Perform bad

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

          Firstly, If you don't have a specific idea on any problem you cannot solve it

          And secondly, bruteforce with simulation which is two nested cycles and five simple ifs is not that hard to implement

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

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

When You Realize After The Contest You're Getting The WA Only Because Of a Typo

edit: and that was me today too I spent one hour because of a typo but gladly solved C in the end

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

Could anyone help me get back to positive contributions? :)pls

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

Thanks awoo! Hope the problems will be as great as the last contest. And i hope to become a pupil again in this contest. Best of luck everyone!

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

.

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

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

I want to be the user with the lowest contribution in codeforces, can you help me?

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

Oh yeah by the way, awoo where's the list of testers?

upd: nevermind, realized previous edu contests didn't have testers either

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

This sleepless night, I'm going to hit my highest rating, you give me a good look.

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

HAPPY VIETNAMESE WOMEN'S DAY – October 20 ❤️❤️❤️

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

Edu Rounds are my best ❤❤

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

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

Hoping to cross 2050! Good luck!

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

time to be specialist

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

Hoping this contest to be math free ...

(Screenshot-2022-10-20-154601)

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

best of luck, guys! my second contest. hope to solve at least A again :)

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

I forgot my notebook and my school's computers don't have any IDEs nor compilers in them.

Gonna use an online compiler. Let's see how it goes

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

Thanks for the round, C is the stupidest problem I have ever seen.

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

    You couldn't solve it doesn't mean the problem was bad.

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

      It's not that I couldn't solve it, it's a trivial n^3 simulation, I just didn't feel like implementing it. I just don't think problem C should be just a straight forward implementation, instead it should be some smart idea.

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

How to solve C? lol

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

Seeing the number of solves of each problem and my experience, I feel that it was a pretty balanced round with a good gradient of toughness of the problems. (Though, some users might have had a sour experience with problem C)

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

How to solve C?

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

    I've just simulated it; iterating through from k = 100 to k = 0, if Alice wins then print out the k and return

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

    Binarysearch, with greedily picking Alice the biggest less than or equal to k-i+1, and Bob picking lowest left value. Storing values in multiset.

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

    To win a game with k turns, the array must have at least k '1', and at least 1 number that is smaller or equal to 2, 3, ..., k. This is because Bob can use a strategy to lock the final move out by adding to each '1' once. Therefore, Bob can lock at most (k-1) '1', so the array must have k '1' to compensate. From there, just search out for the solution!

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

    C can also be solved in $$$O(n)$$$ time without using Binary Search. The important observation to make here is that during the $$$k^{th}$$$ stage Alice must remove an element $$$1$$$ from the array. Thus, the optimal strategy for Bob is to always remove $$$1$$$ (by adding $$$k-i+1$$$ to it) at every turn. If the count of $$$1$$$'s becomes zero before the $$$k^{th}$$$ stage is reached, Bob automatically wins.

    Hence, we store the frequency of every element $$$a[i]$$$ in an array $$$cnt$$$. Note that the answer is zero iff $$$cnt[1] = 0$$$ else the answer will be $$$\geq 1$$$. Now, we iterate over every $$$k$$$ from $$$2$$$ to $$$n$$$, while maintaining a counter $$$cur$$$ which stores the number of elements $$$\geq 2$$$ and $$$\leq k$$$ which have not been deleted yet. In every round, Alice must delete a number $$$\leq k$$$, so if $$$cur > 0$$$ we decrement $$$cur$$$, otherwise we decrement $$$cnt[1]$$$. We then decrement $$$cnt[1]$$$ to account for Bob's move. Now, if at this point $$$cnt[1] \geq 1$$$ then Alice can always make her final move and win if she chooses to play $$$k$$$ rounds. So we update $$$ans$$$.

    Submission: 177175786


    UPD 1: Why is a move by Bob equivalent to removing an element from the array?

    Claim: Any element modified by Bob in the $$$i^{th}$$$ round cannot be removed by Alice in any further round.

    Proof: Let Bob modify the element $$$a[j]$$$ in the $$$i^{th}$$$ round. Therefore $$$a[j]$$$ changes to $$$a[j] + (k - i + 1)$$$. Note that in the following rounds, all the elements Alice removes are $$$\leq {k - i + 1}$$$.
    However, from problem constraints,

    $$$a[j] > 0\implies a[j] + (k - i + 1) > k - i + 1$$$

    Hence, the Claim is proved, and we can say, for the purposes of the solution, that the element has been "removed" from the array.

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

is it just me or C was really challenging? I was so hopeful to become pupil but C destroyed my hopes

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

This is the most stupid C problem ever. For such kind of problems I think rounds must be unrated.

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

readforces

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

.

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

Problem B : Justt think in a simple wayy O_O

Me : Bruhh lets do a simple graph and get 2x WR <(_ _)>

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

Isn't E a dp problem. Let $$$dp[i][j]$$$ means minimum number of extra cactus need to be added for right part of grid from column $$$j$$$ to $$$m$$$ if I put a cactus at $$$(i, j)$$$ .Why am I getting wrong answer.

Anyone help please, Submission: https://codeforces.com/contest/1749/submission/177209214

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

    Yeah, I tried many examples for last 30 mins but couldn't really figure out the counter example. I wish I could see the test 2 now...

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

    UPD: this was invalid testcase. Look at the comment just below it for a test case

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

      I think your test case is invalid.You cannot have cactus on two adjacent cell. But i may have figured out where my solution is wrong.

      1
      6 6
      #.....
      .#....
      ..#...
      .#...#
      ..#.#.
      ...#..
      

      My solution will give 1 but actual is 0

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

      That is not even a valid placement of cacti. Probably the issue of most WA submissions was one-directional dp, while we needed bfs.

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

was it just me or C was really challenging?

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

    I think C is just a C, as always

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

      Actually C is bit easy in this round, but i wasnt able to solve b this round , C is prefixsum problem , in which there should be atleast "k 1's" , "k+1 numbers <=2" , "k+2 numbers <=3" , similarly till k , you can check this Problem_C_Solution

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

        it doesn't need much analysis actually. you just brute force all k and simulate the game. optimal action for both players is just simple greedy

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

Can someone tell me what is wrong with my modular arithmetic please? https://codeforces.com/contest/1749/submission/177211216 I got the algorithm done with 30 minutes left, then spent the rest of the time trying all combinations and figuring out how my modular arithmetic is wrong...

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

    The issue is the range of m. For example, you multiply by m/2. Use (m/2)%MOD instead.

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

      Thanks for replying! I already tried (m/2)%MOD, but it is still wrong... https://codeforces.com/contest/1749/submission/177211216 There are probably a lot of things wrong in there TwT

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

        you have another problem : int n,m; int ans = 0, minu = m; int po[300005];

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

          I already defined int to be long long so the int stuff should work out normally

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

        No, you are still multiplying by m/2. You need to do minu *= (m/2)%MOD; minu %= MOD. In the end, you also need ans %= MOD before if(ans<0)

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

          Sorry for posting the same solution :_: this is the with (m/2)%MOD but still wrong https://codeforces.com/contest/1749/submission/177215823 Do you have any links to learn modular arithmetic in CP so that these problems aren't happening again? Thank you!

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

            Change n, m, ans, etc to long long, then I guess it will be fine. What about wiki page? https://en.wikipedia.org/wiki/Modular_arithmetic Or you can just read the intro section of any elementary number theory book.

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

              Thanks for your help! Unfortunately, I still could not find out what went wrong, maybe finishing it tonight tho...

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

                minu = m % MOD. But seriously, the diagnostics message is already pointing the exact problematic line in this case. It doesn't make sense that you can't debug this.

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

                  thanks so much for all the help! I cannot believe how did I miss that either, was the difference between -20 and +80 this contest lol

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

                change this line : int ans = 0, minu = m; into this two lines :

                int ans = 0, minu = m;
                minu %= MOD;
                

                here is your code getting AC : 177225248

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

                  Oh my god why did I miss that... Thank you so much, forgot the initial part of modding the first

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

Can anyone please share their approach for Problem E?

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

    It's a shortest path problem, you need to find a path of '#' connecting the left side of the grid to the right side. All cells on the path must have the same color if we colored the grid like a chess board. Also you can't have 2 '#' beside each other, so some cells are "banned" of ever becoming '#' (because of the initial placement of '#'). After coding these constraints, it becomes simple dijkstra or 0-1 bfs.

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

after getting ac in a i accidentally submitted c in 'a' instead of 'c' but it didn't pass the first sample test would i get wa in 'a' after system testing?

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

Why is #829 and #830 on same day with only 30 minutes gap?

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

does anyone have a tricky test case for E??

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

Alice and Bob bullied me a lot today...

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

I solved B after noticing that many coders have solved it lol. Actually what I was doing earlier in intuitive way is that selecting the element with least spell which can be transferred to neighbors and then checking that element is leftmost, rightmost or at the center so that accordingly I can add spells to the ans and therefore stucked with WA, and then I realized at the last 3 min of contest that simplest way is to take n-1 min spells and thus finally able to submit it. uffff

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

I keep getting 726722623 as the answer for the fourth test case in D. Did anyone else have this issue?

My approach: In a non-ambiguous array, the $$$i$$$-th element must be divisible by the product of all prime numbers $$$\leq i$$$. The number of such candidates is equal to $$$m$$$ divided by this product (integer division, no modulo). Once the product exceeds $$$m$$$, all arrays of this size are ambiguous. The number of ambiguous arrays of size $$$i$$$ = $$$m^i - $$$ the number of non-ambiguous arrays of size $$$i$$$.

Submission: 177210359

  • »
    »
    18 месяцев назад, # ^ |
      Проголосовать: нравится +13 Проголосовать: не нравится
    ll nam = (m * (m/2)) % MOD;
    

    Doesn't it overflow?

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

      Ahhhh, I see now! Since $$$m$$$ is so huge, I pretty much need to apply the MOD on almost every calculation involving $$$m$$$. Thanks!

      I was able to AC now (but the contest is already over :( )

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

    Why is this true?
    In a non-ambiguous array, the ith element must be divisible by the product of all prime numbers <= i let say ith is 6 and element is 8. gcd(8,6) is 2 but 8 is not divisible by 3.

    array here is 1 1 1 1 1 8

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

      If there is an element 8 at index $$$\geq 3$$$, then you can keep picking the first element until 8 is at index 3. Then you can pick the 8 because $$$gcd(8, 3) = 1$$$, so this array is not ambiguous.

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

        oh i see. so any thing at ith must have gcd of everything from 2 to i not 1 and hence divisible by all the primes. Why did you have overflow problem? Wouldn't that be at max 10-15 primes before the product is larger than 10^12

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

          The overflow is because $$$m$$$ itself is as high as $$$10^{12}$$$. So even for $$$n = 2$$$, the number of non-ambiguous arrays is $$$(m * (m/2)) \% MOD$$$, but the intermediate $$$(m * m/2)$$$ already triggers overflow.

          In fact, I used binary exponentiation to calculate $$$m^i$$$ (total number of arrays of size $$$i$$$), but the multiplication for odd $$$i$$$ overflows unless I apply the $$$MOD$$$ on the base $$$m$$$ itself.

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

    Also you can check for such overflows by compiling with the flag -fsanitize=signed-integer-overflow. Helped me debug the exact same error

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

Can anyone share their approach for problem D?

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

can anyone tell me their approach for problem c? I had couple of approach but none worked.I thought one with binary search,tho it was taking o(n^2) overall.

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

    It's optimal for Alice to always pick the largest valid number, while Bob always picks the smallest number. This means Bob will eliminate the smallest $$$k - 1$$$ numbers. Therefore, if Alice can win, she can win by picking only the $$$k$$$ numbers that are after the first $$$k - 1$$$ numbers in sorted order. In other words, she can pick the $$$k$$$-th number when her upper bound is 1, she can pick the $$$(k + 1)$$$-th number when her upper bound is 2, she can pick the $$$(k + 2)$$$-th number when her upper bound is 3, and so on.

    We can binary search to find the largest $$$k$$$ that fulfills this condition. My submission: 177165675

    With how small $$$n$$$ is, a simple linear check for each $$$k$$$ should work too (instead of binary searching).

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

How to solve E?

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

What is wrong in problem $$$D$$$ in this logic?

If $$$gcd(a[i],j)>1$$$ for all $$$2 \le j \le i$$$ and $$$2 \le i \le n$$$ then, the array would be unambiguous (obviously), also if $$$gcd(a[i],j)=1$$$ for some $$$2 \le j \le i$$$ the array would be ambiguous, because after $$$i-j$$$ moves by removing $$$1^{st}$$$ element, the $$$i^{th}$$$ index becomes $$$j^{th}$$$ index now, and now instead of removing the $$$1^{st}$$$ element in remaining array in $$$(i-j+1)^{th}$$$ move, I will simply remove the $$$j^{th}$$$ element.

But something is wrong as I can't seem to pass $$$4^{th}$$$ sample :(

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

    In Line 16: curr=(curr*m)%MOD; can overflow, since $$$m$$$ is so freaking huge. You should apply the MOD on $$$m$$$ first, before multiplying.

    Changing it to curr=(curr*(m % MOD))%MOD; passes the fourth test case, and will probably be Accepted.

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

How to solve D?

We know that one of the b would be an array of all 1. For something to be non-ambiguous, it must not have anything other than 1 in the b array.

My approach that ith element must be relative prime to all number from 2 to ith. Because if this is not the case, then at some point the gcd(ith, 2-i) != 1. It is just a matter of calculate how many number are possible that is less than m at ith.

How do you even do this though?

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

    Exactly man! Now I too made the same observation, now just see that since the product of first $$$12$$$ primes (upto $$$37$$$) is greater than $$$1e12$$$ $$$(m < 1e12)$$$, so any array of size > $$$37$$$ must contain an element $$$a[i]$$$ which would not be a multiple of some prime $$$p \le i$$$. So, any array of size > $$$37$$$ must be ambigious

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

    In an un-ambiguous array, the $$$i^{th}$$$ element must have $$$gcd>1$$$ with all $$$2\leq j\leq i$$$. This means it should be divisible by all primes $$$\leq i$$$*. The count of values $$$\leq m$$$ that are divisible by all primes $$$\leq i$$$ is $$$\lfloor \dfrac{m}{\prod_{j=1}^{j=i}{j\cdot isPrime(j)}}\rfloor$$$.

    *Why the $$$i^{th}$$$ element should be divisible by all primes $$$\leq i$$$: In an un-ambiguous removal sequence, the $$$i^{th}$$$ element's position will decrease by $$$1$$$ after each removal. So, it will hit all the prime positions $$$\leq i$$$, and any composite position $$$\leq i$$$ is just a combination of primes $$$\leq i$$$.

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

      How to proof the conclusion in the last part?Is it a theorem or something else?

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

        Which conclusion exactly?

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

          "The count of values ≤m that are divisible by all primes ≤i is ⌊m∏j=ij=1j⋅isPrime(j)⌋"

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

            For any value to be divisible by all the primes $$$\leq i$$$ it has to be divisible by their product ($$$prod=\prod_{j=1}^{j=i}{j\cdot isPrime(j)}$$$). These values are: $$$prod, 2\cdot prod, 3\cdot prod, ..., k\cdot prod$$$, where $$$k$$$ is the maximum integer such that $$$k\cdot prod\leq m$$$. So, $$$k=\lfloor \dfrac{m}{prod}\rfloor$$$

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

            There is nothing to prove bro.

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

The $$$u=v$$$ case of problem F is very similar to Sprinkler from JOI Spring Camp 2022. Dealing with $$$u \neq v$$$ is pretty easy.

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

Almost solveD...
Just avoid overflow issue and now get passed. Feel sad...

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

I have a two pointers solution for B here.

I'm not sure if it works 100% of the time as edu round pretests are usually weak. Can anyone try and hack it?

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

Problem C can be solved in O(n*logn*logn) with binary search + multiset. Why were the constraints kept low for this problem? Even a O(n^3) solution will pass.

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

I see many solutions of D calculating LCM directly. Idk how lcm is not overflowing. I was thinking of same approach but I thought lcm will overflow.

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

    we will calculate it until lcm<=m (m<=1e12) .if lcm>m there will always be ambigous solution.

    so there wont be overflow

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

Anyone else overcomplicate B?

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

According to me , in problem B the testcase given below should have answer 244 but the correct answer is 242. Can anyone please explain why?

1
7
1 50 10 100 10 50 1
1 5 2 7 5 6 1

Also when we remove an element do we have to add its strength to both of its neighbors or just one of them?

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

    You add to both neighbors if it has two neighbors. Also, to get 242, u remove the left 3 then remove the right 3 and then remove middle.

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

    remove the elements in this order 7 5 6 1 2 3 4

    you will get 242

    we should add its strength to both neighbors

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

    The answer is the sum of all $$$a[i]$$$ and $$$b[i]$$$ minus the largest $$$b[i]$$$.

    This is because you can always kill an enemy who is currently at either the left end or the right end, so the $$$b[i]$$$ gets added only to one enemy, and never to two enemies. The last enemy you kill will not have their $$$b[i]$$$ added, so the optimal choice is for the maximum $$$b[i]$$$ to be the last enemy to kill.

    So one solution here is to kill the first three from left to right (each $$$b[i]$$$ gets added to only one enemy), then the last three from right to left (again, only added to one enemy), and then finally kill the remaining element (which has the maximum $$$b[i]$$$, but it is not added to anyone's health, due to being killed last).

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

My head hurts after getting WA 5 times in a row on C

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

D is too easy for its position.

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

Nice A And B is also nice but not as good as A

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

    Was A really a good problem? All you had to check was n == m.

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

      Really good.

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

      Yes, it's a good problem imo. It's not an arbitrarily contrived scenario, nor is it a trivial problem (it may not be immediately obvious as to why $$$n != m$$$ suffices). The simplicity of the solution only makes it better.

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

How to solve problem D I was only able to come across observation that For an array to be not ambiguous It's Ith element must not be divisible by 2,3,...i for all I >= 2 (1 based indexing) How to approach this question further I am goota stuck here New methods are also appreciated Thanks in advance

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

    You are pretty close. Just think about is there any array with zero or one removal sequence?

    At least two is equivalent to excluding zero and one.

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

I want to be the lowest contribution on codeforces please help me

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

Plese help me To become lowest contributor in codeforces history

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

Can someone explain D ??

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

    Copied from my other post:

    D. Counting Arrays

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

      Thank u

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

      can you explain how you are calculating the

      number of k from 1 ... m for an i such that , GCD(k, p: p | i) > 1

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

177174924 do this one is ok?

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

I got 66th place (and 18th for rated participants); pretty good!

My solutions (video):

A. Cowardly Rooks

Solution

B. Death's Blessing

Solution

C. Number Game

Solution

D. Counting Arrays

Solution

E. Cactus Wall

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

For Problem B, the constraint on a is (1 <= a <= 10^9) but in the pre test 3 Test case 13 one of the input is 2453494488, this is not expeted right 1749B - Подарок смерти 177245405. Can anyone confirm is this fine

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

I FUCK EDUCATIONAL ROUND. Educational Codeforces Round 138 [Rated for Div. 2] was the worst match I've ever seen.Fuck you....................................

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

Sorry for posting such lenghty code instead of a link.

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

    Never post code like this way. You should use link of the code.

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

Waste almost 30mins to solve Problem D just because of OVERFLOW. XD

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

Nice !

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

Can anyone please tell what is be wrong with this solution 177255794? I have tried to make sure that overflow doesn't occur anywhere, but still for the large test cases, I am getting a different output.

Edit: nvm, found my mistake

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

I don't know why people still don't use templates for modints. This can help you avoid adding additional logic for overflow and makes code look a lot cleaner. And for taking inverse you can just put a simple division operand and it will handle everything. Code and usage is in spoiler

Modint template(which I took from someone whose name I don't remember)
»
18 месяцев назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Problem E is easy if you solved this recent Indian ICPC problem.

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

Now I see the disadvantage of doing problems in D-C-B-A.

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

When will system test start?

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

when will the editorial be updated ?

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

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

In question number Everyone approach is Sum(health)+sum(strength)-max(strength) But it fails on test case 4 2 6 7 3 3 6 1 5 its correct ouput is 28 But its outout from this approach is 27

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

    are you sure????

    It is the correct solution.

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

      Yes I am sure 2 6 7 3 3 6 1 5 You can check by doing dry run

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

        2 6 7 3 3 6 1 5

        +2

        9 7 3 6 1 5

        +3

        9 12 6 1

        +12

        10 6

        +10

        =27

        Why not 27? You sure what? Lmao

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

        just wait for the editorial and try to understand why the solution is like that.

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

          I understand Sir...We have take only boundaries values so that sum can be minimize

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

            then why don't just simulate this solution in your testcase?

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

Ratings updated preliminary. Unfortunately Mike won't be in touch until Monday, so cheaters will be removed later.

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

Problem A does not require rook positions [Lol] [Lol]

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

Please provide editorials....asap

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

Where's the editorial? Please post it as soon as possible.

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

Thanks for the contest! I really enjoyed upsolving(I had school when it was held T_T).

I think c,d are interesting and I like solving e a lot(even though I completely bricked it for the first 1 hour i spent solving it :P)

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

EDIT: Please disregard the comment. This is due to an issue in the way I printed the test.

There is potentially an issue in the tests of https://codeforces.com/contest/1749/problem/E It seems like the case 17 of the test 2 violates the constraint of no side adjacent cacti in the grid. However, in the statement it states that the initial state satisfies the constraint. Following is the test case. Am I missing something?

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

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

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

Never give up :)

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

    Grats to you for finding out that upper_bound is essentially the same with lower_bound with a very small value added. You tried to fool the plagiarism test by swapping out one function and making the indents a big mess. Good try, but I think you failed.

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

      UPD (Yes, it had to be a separate comment): Thank you, comment OP, for trying to conceal your sins and making me look like a motherfucker. Thank you very much.