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

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

Привет! В 12.09.2022 17:35 (Московское время) начнётся Codeforces Round 820 (Div. 3) — очередной Codeforces раунд для третьего дивизиона. В этом раунде будет 6-8 задач, которые подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Однако все желающие, чей рейтинг 1600 и выше могут зарегистрироваться на раунд вне конкурса.

Раунд пройдет по правилам образовательных раундов. Таким образом, во время раунда задачи будут тестироваться на предварительных тестах, а после раунда будет 12-ти часовая фаза открытых взломов. Мы постарались сделать приличные тесты — так же как и вы, мы будем расстроены, если у многих будут падать решения после окончания контеста.

Вам будет предложено 6-8 задач и 2 часа 15 минут на их решение. Одна из задач интерактивная. Не забудьте прочитать инструкцию по интерактивным задачам.

Штраф за неверную попытку в этом раунде будет равняться 10 минутам.

Напоминаем, что в таблицу официальных результатов попадут только достоверные участники третьего дивизиона. Как написано по ссылке — это вынужденная мера для борьбы с неспортивным поведением. Для квалификации в качестве достоверного участника третьего дивизиона надо:

  • принять участие не менее чем в пяти рейтинговых раундах (и решить в каждом из них хотя бы одну задачу)
  • не иметь в рейтинге точку 1900 или выше.

Независимо от того являетесь вы достоверными участниками третьего дивизиона или нет, если ваш рейтинг менее 1600, то раунд для вас будет рейтинговым.

Спасибо MikeMirzayanov за платформы, помощь с идеями для задач и координацией нашей работы. Задачи были придуманы и написаны командой Университета ИТМО: MikeMirzayanov, myav, Gol_D, Aris, Gornak40, senjougaharin и Vladosiya.

Также большое спасибо: Kniaz, BledDest, Svyat, Be_dos, Timur2006, FelixDzerzhinsky, alphabet321, FedShat, vsinitsynav, Jostic11, erankyun, _Roma_, KKT_89, ABalobanov, lightseba, powergee101, DafuQ_o и AshrafEzz за тестирование раунда и весьма полезные замечания. Список тестеров будет пополняться.

Всем удачи!

UPD 1:


Мы во время раунда (и мы скучаем по Gornak40 и Gol_D).

UPD 2: Разбор

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

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

Автокомментарий: текст был обновлен пользователем Aris (предыдущая версия, новая версия, сравнить).

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

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

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

Good luck for everyone . Do your best to be the best !!

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

Deleted

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

Its the 1729th codeforces round! The Hardy-Ramanujan number which is very well known in Mathematics

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

Finally, my first out of comp-

wait this is div.3, not div.4

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

As a tester, give me a contribution, please

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

Good luck to everyone and I hope the problems will be enjoyable!

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

First unrated DIV3 ❤️, hope to solve 6 or more problems this time!

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

Hope to be Expert this round!

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

Codeforces Language Picker -- chrome extension to fix codeforces language picker.

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

Hopefully I'm gonna be green this contest.

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

Div3 Ftw

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

Автокомментарий: текст был обновлен пользователем Aris (предыдущая версия, новая версия, сравнить).

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

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

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

As a tester, I hope you enjoy the problem set! Good luck and have fun!

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
One of the problems in this round is interactive
;_;
»
20 месяцев назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

Div. 2.5

  • »
    »
    20 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится -29 Проголосовать: не нравится
    Комментарий удален по причине нарушения правил Codeforces
    • »
      »
      »
      20 месяцев назад, # ^ |
        Проголосовать: нравится +40 Проголосовать: не нравится

      Please don't talk about contests before they are finished.

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

        oh sorry but i didn't tell anything consider a spoiler + easiness is a mysterious ( sorry my english is not good) term maybe its just easy for me right? + i see people say mathforces speedforcess etc.. in other rounds why this comment consider deferent from them

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

          In my opinion ANY comment referencing the contest during it shouldn't be allowed, I'm not sure to what extent the codeforces staff want/can block this type of unfair comments, but in any case saying a problem is easy is a bit worse than saying all problems are easy (although I agree they should be removed as well)

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

deleted

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

D is much easier than C.

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

any idea for problem no E?? binary search is one solution but it requires 60 quarries.

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

    you can just ask 25 pairs (a, b) and (b, a), and you are able to print the answer once you've got different paths for an arbitrary pair. The probability of getting same path for each pair is 2^(-25).

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

    u can just try every pair {1, i} and {i, 1} for i from 2 to 27. In each two query ({1, i} and {i, 1}) u have a 50% chance that u get distance in different directions. If u do, then the answer is ans1 + ans2, where ans1 and ans2 is results for queries. Also, if u get -1 at some point, it means, that the previous i was the greatest vertex in graph, so it should be the answer. So print i — 1 and return

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

      Instead we can just take the pair (1,2) and query it 50 times. There is a probability of (1-2^-50) that we will get two different numbers. Just summing them ( with a +1 ofcourse) will give the result.

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

        No, I too missed that part in the statement at first: after an answer is determined for a specific query, it wont change, so it will keep outputting the already computed value

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

      Well, there is a possibility that all pairs are equal, right?! So why is the solution correct!! Could he give a wrong answer in my opinion.

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

        yes, but that possibility is really really low, so it will almost certainly pass (and if it miraculously doesn't, submit a second time)

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

        Yes, its possible, but the probability of it happening is equal to 1/2^25, which is veeeery small, so u can hope that it wont happen)

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

          Please, can you explain where did the number come from(1/2^25)?

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

            there are 25 pairs, the probability of each of them to equalize is 1/2 and also the probabilities are unrelated, so the probability for all of them to fail at the same time is (1/2)^25

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

              Moreover, if you want your solution to fail then the average number of times you need to submit to get first WA is 2^25 ~ 10^7.5

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

                Actually a bit less, remember there are multiple test cases. But in general yes, that's what I said, the solution won't fail

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

      Gosh, I thought about that, but I was like "hey, this won't pass for whatever test case, there must be another way"...

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

For problem E, what was test case 18? I got completely stuck in the testcase, I was using modified ternary search for the problem. If that is not the right way to solve it, can someone please tell how to approach the problem?

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

Was E ternary search?

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

Can anyone help me with problem E? why is it taking more iteration than 50? although it should take only log(1e18) < 50 (that is less than 50). My submission

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

About problem E: what is the probability that out of 25 pairs of queries at least one pair of query will give distinct answers, e.g. query(a, b) != query(b, a)?

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

    Roughly 1-2^-25 when n is big enough.

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

      It is said that it may be equal but how you are so sure that it will be equal with 25 queries

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

      But the probability of WA is not completely 0. Is there any deterministic solution?

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

        Most likely not. It's the same as the Polynomial Hashes, there is a very small chance of failure, so nothing wrong probably

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

          I thought that codeforces round always has some deterministic solution.

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

            Well, again, Polynomial Hashes are not deterministic, yet still it's a popular way to solve problems on strings. There is nothing wrong about it. You just need to make sure the chance of failing is very small

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

              I get it but usually there is always a deterministic solution. Polynomial hashes has deterministic alternatives.

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

                Not always

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

                "usually there is always a deterministic solution" well, there IS, it just needs more (than 50) queries. People often confuse a problem with a problem statement. You should not consider a problem statement in isolation, rather all of statement, input format, input constraints as a package. For example, for any NP Hard problem, we all know that there are no polynomial solutions. That does not mean they are not solvable. You can set small constraints and expect an exponential solution with some optimization here and there. In other words, this is the difference between math olympiad and programming contest.

                I hope that satisfies your itchy feelings about not having a 100% guaranteed solution. This problem was designed and the constraint was set specifically for a probabilistic solution. If more than 60 queries allowed, one can find an exact solution using binary search.

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

      I see, thank you.

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

I think that problem E is more suitable for div 2,it's really hard !!

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

    No, the idea, especially with No hacks, 50 test cases, really says it uses random. Also, as there is no binary search, you can only rely on distances, but they could all be simply distances on a part of a graph, so you cannot guarantee the answer is correct. The only way is to minimise the chance of fail

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

    We rarely have "easy" problems with randomized solutions. This is a good way to introduce randomized solutions to beginners

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

Most unbalanced round ever, downvote.

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

Can anyone help me with my solution for Problem E? why is it not working and taking more iterations than 50? although my solution should run within log(1e18) < 50 (correct me if i m wrong here).

submission

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

cool E

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

Would you please review my code of E. Guess the Cycle Size?

I think my algorithm is good and random enough to pass this problem (I frequently think so), but I fail on test27. Where am I wrong, please?

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

In question E how you can be so sure that ans will be find by just finding it upto 25

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

According to some cursory analysis, my solution for E seems to have a 99.391488785% chance of passing a set of 100 test cases. Don't think this is the intended solution.

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

    i guess it is (i did the same btw), because hacks are disabled and there are 50 tests only. Moreover, the problemsetters did even tell us that amount of tests is 50, which is kinda strange.

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

      The problem emphasized "with equal probability" in bold letters, and also made sure to state that "? a b" will not necessarily yield the same result as "? b a". They also mentioned the number of tests in the jury (which I've never seen mentioned before in the problem).

      So yes, I am pretty sure the intended solution is to try "? a b" and "? b a" until you get something different. You do need to make sure you try distinct pairs each time, but there are easy ways of doing that (including ways that guarantee the correct answer if the result is ever -1). My submission: 171950029

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

Great round <3 <3 <3

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

How to solve C?

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

    Find all the characters in string that lie between letters s[0] and s[n — 1] and use all of them for jumps.

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

How solve E

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

    I try every pair {1, i} and {i, 1} for i from 2 to 27 ^^

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

      why till 27?? can you please explain?

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

        Because there is a total of 50 queries, and for each vertex you need to use 2 queries

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

          Hi Noobish_Monk. I have a doubt. If I print all my queries as 1 and 2 for 50 times, then if I get 2 different sets in my answer then it's just the sum . What's wrong with this approach. And the probability that I always get the same answer is 1/power(2,50) which should be approximately 0. Why do we need to print for 27 queries ??

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

            The answer for the same query is the same However queries ? a b and ? b a are different So you can't just ask 1 2 and 2 1

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

        You can also do it from 4 to 29, because the problem states that n ≥ 3.

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

Solution for E was probably meant to be different, But here is how I AC it:

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

    IT'S IS THE INTENDED SOLUTION

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

      Can you explain how it is the intended solution like very first thing that comes to mind is Binary search but it didn't work.

      I also tried the concept of binary search on infinite array but it failed at test 18.
      
      • »
        »
        »
        »
        20 месяцев назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Because of how many times the statement highlighted the idea of equal probability i think this is the intended solution.

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

        There is no deterministic solution that guarantees 100% correctness. Suppose I was an adversary that doesn't have a specific graph in mind, or even a value of $$$n$$$, but I make answers to screw you over while always ensuring that there exists some graph that is consistent with all my answers. Then I can always ensure that each answer I give will be either -1 or some distance that is below the established lower bound from the program.

        With 50 queries, you can only gain enough information to distinguish between $$$2^{50}$$$ possible answers, However, the range for $$$n$$$ goes up to $$$10^{18}$$$ (which is much larger than $$$2^{50}$$$), so you cannot guarantee a correct solution.

        The problem dropped a lot of hints suggesting the randomized approach ("equal probability" in bold, clarifying that "? a b" and "? b a" are processed independently, specifying the number of jury tests, etc), so I'm quite sure this is the intended solution.

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

          If you want your solution to fail then the average number of times you need to submit to get first WA is 2^25 ~ 10^7.5

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

            Why can't we just use pair 1,2 and 2,1 25 times ? What is the probability that use these 2 pairs wont give me the answer in 25 queries ?

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

              It is stated that the same pair will give the same result for all requests.

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

              The problem states that repeating the same query will yield the exact same result every time. There is only a 1/2 chance that "? 1 2" and "? 2 1" will yield different results. If they both produce the same distance, then you will always get the same result for "? 1 2" or "? 2 1", so your probability of success will remain as 1/2. This is only for one jury test, so the probability of getting all 50 jury tests would be $$$\left(\frac{1}{2}\right)^{50} \approx 0.00000000000008817842\%$$$, which is not worth trying.

              But by trying different pairs each time, there is a 1/2 probability of success for each distinct pair. The probability that all 25 pairs fail is $$$\left(\frac{1}{2}\right)^{25}$$$, so the probability of being successful at least once is $$$1 - \left(\frac{1}{2}\right)^{25}$$$. A single success is enough to guarantee the correct answer. We need to pass 50 jury tests, so the probability of ACCEPTED verdict becomes $$$\left(1 - \left(\frac{1}{2}\right)^{25}\right)^{50} \approx 99.999850988\%$$$. It would be extremely unlikely for such a submission to fail, and I would be very interested to see if there is anybody who met this unfortunate fate.

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

                Thanks for your explanation. This is helpful.

                I read this statement of same result produced for same query but didn't realise how important this was.

                Even after reading this, somehow I thought that using 1,2 & 2,1 still is random. But it seems like that the interactor is caching the result of the query.

                Similar to these lines, IMAGINE if 1,2 & 2,1 produced different results with 1/2 prob but they can produce different result every time, then we can just query 1,2 & 2,1 50 times right ?

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

                  If duplicate queries were rolled independently, then yes, you can just query "? 1 2" 50 times. You can mix in "? 2 1" as well, but it is completely identical to "? 1 2" in this case, so it doesn't matter. In this scenario, the probability of failure becomes $$$\left(\frac{1}{2}\right)^{49}$$$ (all 49 queries after the first one match with the first query).

                  Probability of AC becomes much higher then (though it was already high to begin with), and the implementation becomes much easier too (though it was already easy to begin with).

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

              Even without luck being involved, it can very well be the case that 1 and 2 are on opposite side of the cycle so longer and shorter both lengths are INDEED equal. So you must take different pairs to keep a backdoor in case your queried vertices fall on opposite sides.

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

                Ah, you're right; I forgot about that case. We can deal with this by simply performing 25 queries of "? 1 2" and 25 queries of "? 1 3". This slightly hurts the probability of success, but it's still very high.

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

                  25 queries of "? 1 2" gives the same answer each time. So you are really just wasting 24 queries in this case. Same goes for "? 1 3".

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

                  onebit1024 This was part of a discussion on the hypothetical scenario that each query is rolled independently, even if the same query was made in the past. In such a scenario, it would be optimal to repeat the same query (e.g., "? 1 2") 50 times instead of trying to find new pairs. If all 50 queries yield the same result, then the guess should be on twice this value (since it's likely that both paths have the same length).

                  Obviously, for the original problem E, repeating the same query would be a waste, so you have to keep trying distinct pairs (so the possibility that both paths have the same length would not be an issue at all).

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

                  Oh ok, sorry, I didn't realize that you were discussing a hypothetical scenario. Well in this scenario, this approach will work.

                  actually, during contest I tried the same thing because I missed the part where (a,b) would give the same result each time.

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

          "Suppose I was an adversary" I don't need to read anything else. The solution will fail against an adversary. That's the whole point, that it was not an adversary, and it will honestly return any of the shorter or longer path from a to be with equal probability, without ever trying to make you fail. The moment an adversary comes into play, it will need binary search i.e. 60 queries.

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

            The fact that an adversary will always be able to screw you over is definite proof that there does not exist a deterministic solution that guarantees correctness, which further suggests that the randomized approach is, indeed, the intended solution. Some people were unsure if that was the case, but I don't actually think there should be any doubt.

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

Balanced round a pity i didnt get E

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

Can anybody explain how they came up with the number 25 that checking this many pairs will have a different result?? really didn't get this part.

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

    It's probability theory. We have a chance of success 1/2, same for failure. As we ask 25 times, we have a chance of failure equal to 2^(-25), which is a VERY small number

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

    Since we have at most 50 queries, we can check 25 pairs in both ways. Assume we got a pair (a, b). Checking it both ways means that you chack a pair (a, b) and (b, a) since it can give different results. Since the output path length is randomized between the 2 paths(the short and the long versions, since it's a cycle), it's 50% chance for each to output.

    Asking 25 queries in this format and checking for -1 or different results for the (a, b) & (b, a) query. If you get -1, it means the last vertice(call it v; 2<=v<=26) is the correct answer, since the current one is out of bounds and the last one wasn't. So we output the last valid run. If the results differ, you can output sum of the results, since you got both paths for (1, v) pair and their sum is a complete cycle.

    This one failing has quite a low chance, since it's 1/2 for each path to be given for a query, it's 2^-25% chance of this idea failing, if I am not mistaken.

    I hope this makes sense.

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

    You're allowed 50 queries. You make a pair of queries "? a b" and "? b a", and hope that you get different results for these two. If the results are different, then you can add the two results to get the number of vertices.

    I'm not sure if the guess counts as a query, but if it doesn't, then you have 25 pairs of queries to get this. If it does count, then you only get 24 pairs of queries, plus an extra query, and one for the answer.

    It's annoying that this is a randomized solution, but the probability of this failing is less than 1%, and there are many hints in the problem statement itself to suggest that this is the intended approach (equal probability in bold letters, mentioning that "? a b" and "? b a" are rolled independently, specifying the number of jury tests, etc).

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

    Also if you ask why the numbers of allowed querry is not greater it's because with 60 querry (which is log2(1e18)) you can just get the result with a binary search

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

Very interesting problems, especially F!I have really enjoyed it!

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

I think my A problem is brief enough.Is there any person can give me some advice to simplify my approach further?

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

Can anyone tell me what i am doing wrong in my solution of problem C ?

My submission

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

    As the solution uses sorting I might suggest it's that the last index is not the last in your sequence. Or you could possibly go in the wrong order if p >= q or less than q. IDK, but that's most likely the mistake

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

    Try "baba".

    I fell into the same trap and got WA. Thankfully, I figured it out before the contest was over.

    I didn't read your code (but I checked "baba" via custom invocation), but it's most likely due to your use of sorting. The assumption that your range covers all instances of first character and all instances of last character only applies if first character < last character. In the scenario where last character < first character, your range likely does not capture all instances of first and/or last character.

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

    Here is the counter case for your solution: 1 yydia

    correct ans: 24 5 1 2 4 3 5

    Your ans: 24 4 1 4 3 5

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

    Now it's Accepted!

    Accepted

    Thanks Noobish_Monk Andalus Nikhil19259

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

https://codeforces.com/contest/1729/submission/171949266 Can anybody help to find a short test where my solution for C does not work?

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

Е one love

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

Whats wrong with my solution to C? 171872810

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

To the author of problem E: how did you generate the tests? I'm curious to know. Btw, awesome contest!

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

    Yeh same doubt regarding the E part of the contest, in all the test cases, input is in this form-

    3 9195979e279504391c49d2f080c1d8c755d044ca what is this — 9195979e279504391c49d2f080c1d8c755d044ca ?

    Shouldn't this be a long integer? Thanks.

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

    I think you store the length of the permutation as well as it's index in sorted order. Not sure though...

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

i was trying to solve F with condition s(l1,l1+(w-1) ) != s(l2,l2+(w-1)) when i read l1 != l2 then when i realaize my mistake the contest was over :(

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

Can someone find a mistake in my code for 1729C - Прыжки по плиткам?

Code: 171911705

Thanks!

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

    Try "baba".

    I fell into the same trap and got WA. Thankfully, I figured it out before the contest was over.

    I didn't read your code (but I checked "baba" via custom invocation), but it's most likely due to your use of sorting. The assumption that your range covers all instances of first character and all instances of last character only applies if first character < last character. In the scenario where last character < first character, your range likely does not capture all instances of first and/or last character.

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

Oh my god I solved E. I have never tried random algorithms in competitive programming ever. Too bad the contest is over by now, but holy fuck I would never believe that it would actually work. Holy Jesus. 171950813

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

Nice problem D! It makes me difficult even though it's only div 3. Can anyone give me a solution ?

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

    For C or D?

    For C, jumping directly to the end yields the minimum cost, which is |last character — first character|. How to maximize jumps? Observe that if you're in $$$\alpha$$$ and you jump to $$$\beta$$$ and then to $$$\gamma$$$ such that $$$\alpha <= \beta <= \gamma$$$, then the cost is the same as jumping directly from $$$\alpha$$$ to $$$\gamma$$$. So you can jump to any character in the range [current character, final character] and it would not affect the final cost.

    For example, with "logic", you can go from "l" to "i" to "g" to "c" because "l" > "i" > "g" > "c". To maximize jumps, you need to visit every character in the range [starting character, final character] in order (either non-increasing or non-decreasing order, depending on the relative order between first and last character).

    For D, if you calculate $$$y - x$$$, you basically get the person's balance from paying for their meal. This can be negative if they don't have enough money. You can then sort the balances, and try to pair the one with the lowest (i.e., most negative) balance with the highest balance. If the result is non-negative, it's a valid pair, and you can move on. If not, then the lowest balance is hopeless and you move to the next lowest balance (try with highest balance), and so on.

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

Would you please review 171943515? Maybe it is wrong when $$$n$$$ is small, but I do not know how to fix it.

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

    int isn't big enough to hold the values required.

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

      Damn it you hacked me twice ^_^. Thank you very much!!!!!!!!!! When debugging in a limited time, it is easy to ignore some very basic facts...

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

In problem E, all the AC solutions I've checked till now are querying

$$$?$$$ $$$1$$$ $$$x$$$ and $$$?$$$ $$$y$$$ $$$1$$$ where ($$$2 \le y \le 26$$$).

But how is that acceptable when the interactor chooses with a certain probability? Yeah, the probability of getting a correct answer is very close to $$$1$$$ ($$$1 - 2^{-25}$$$) but certainly not $$$1$$$. I thought of such a solution but ignored thinking since it can create a situation where same solutions may get AC and WA which is unexpected. I don't think this was a good/standard problem for a contest.

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

    I did feel bothered by the fact that the intended solution is randomized, especially since I was trying much more complicated approaches before the contest ended, and only got AC after it was over.

    However, I think it's really a matter of opinion on whether this is appropriate. Randomized algorithms have numerous practical applications in the real world, so this kind of recognition that a randomized algorithm would work is a good skill to have, which can be argued as being among the type of skills that competitive programming should cover. Also, the problem did drop a lot of hints that this was the intended solution ("equal probability" in bold, mentioning that "? a b" and "? b a" are processed independently, mentioning the number of jury tests, etc), so I think it's justified in this case.

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

    I personally think it was a great problem (maybe I have some bias since I solved it quite quickly in the contest). It makes you think outside of the box and consider non standard methods that you don't regularly see in CP, which ultimately is a great way to test/improve problem solving.

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

Can someone explain how does the rating work, I'm confused a little bit because I'm new to codeforces.

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

In problem E ,is it really fair to give such a probability based question in a contest because it's not like the probability of getting them all equal is zero right,just because of that many of us didn't go for that approach and the binary search one was exceeding the queries(which should actually be the intended solution).

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

    The probability of success is over 99%, and the problem dropped a lot of hints to go for a randomized approach ("equal probability" in bold letters, clarifying that "? a b" and "? b a" are processed independently, mentioning the number of jury tests), so I think this was justified. I understand how one would assume there is a deterministic solution, but randomized algorithms have numerous practical applications in the real world, and recognizing when a randomized algorithm would be effective is a valuable skill for a programmer to have, so it can be argued that it should fall within the scope of competitive programming. I understand the concerns, but I think it's a matter of subjective opinion and cannot definitely be ruled as "unfair".

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

Is there a deterministic solution to the problem E, which always works no matter how the generator is configured?

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

    No. An adversary can always ensure that the result for each query is either -1 or some distance that is less than the current lower bound that was established. Therefore, there are essentially two possible types of information to be gleaned from a single query. With 50 queries, this only allows identifying up to $$$2^{50}$$$ different values, which is less than $$$10^{18}$$$. So there is no 100% correct deterministic solution.

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

Is square root decomposition the intended solution for problem F?

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

    there is no need in sqrt decomposition, the only data structure we actually need is prefix sum array

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

In problem E, shouldn't it be "in C++ you should use function fflush(stdout)"?

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

Any hints for G?

  • »
    »
    20 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится
    Hint1
    Hint2
    Hint3
    Hint4
    Code
»
20 месяцев назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

An interactive problem without Binary Search ,,,,,, surprising

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

how to solve problem c? I used priority queue but got wa

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

    The minimum distance is simply the distance from jumping directly from the first to the last.

    How to maximize jumps? If you go from $$$\alpha$$$ to $$$\beta$$$ to $$$\gamma$$$, where $$$\alpha \leq \beta \leq \gamma$$$, the total cost is the same as going straight from $$$\alpha$$$ to $$$\gamma$$$. So you can keep jumping to an intermediate index, provided that the character in it lies between the previous character you were in and the next character that you're going into. So if you need to jump from "b" to "f", then you can jump into all of the characters in the range [b, f], in non-decreasing order. By the same argument, if your final character is actually smaller than the first character, you can still jump into all characters in the range, but in non-increasing order this time.

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

Anyway,I dont think E is a good problem.

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

So I was just casually looking at the hacks corner and found a few hacks for problem A which seem way too odd.

171954115, by: vaibhav_1710 to: chaudharyvaibhav184; 171952586, by: andreifilimon to: wavetome;171877008, by: mihir2808 to: suiiiii

Now how and why in the world did all these people put an a is equal to some random no. check? I don't know where to report these so I'm just posting it here. There are points for hacks so this should count as a violation right?

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

I like problems with randomized solutions. It would be great if there were more such problems as today's E.

Do you like randomized algorithms?

— Yes

— No

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

    I don't know what to say about $$$E$$$, I had that idea early, but I doubted it would work, then i submitted it in the last minutes (because why not) and somehow it worked, but I got high penality.

    I'm certain that many people (maybe hundreds) had this solution in their head but they didn't try because it depends on luck :D

    So i don't like this random algorithm.

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

Any hints for F? I'm guessing there's some number theory property related to mod9 as $$$w$$$ can overflow int64.

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

    Hint: any number in decimal mod 9 = the sum of its digits mod 9. It would be a good exercise to prove this statement.

    • »
      »
      »
      20 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится
      Hint about proving this statement & other similar statements
»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
  • »
    »
    20 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Try this input:

    2
    azz
    bz
    

    The map yields values from 1 to 26. When adding elements to the 2D vector, the first index is given by the map, so the first vector index also ranges from 1 to 26 (1 for 'a', 26 for 'z'). However, when clearing the vector at the end of the test case, only indices 0 to 25 are cleared. So any instances of 'z' saved from earlier test cases (at v[26]) will continue to remain in future test cases.

    (note that v[26] is technically out of bounds, since v was declared to have size 26; this will not necessarily be detected as an error, and the program may continue to use v[26] as the unallocated memory location that sits 26 steps from the start of the vector, until an issue arises with this location later)

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

In problem E, hacks are disabled. Is system testing also disabled or can it be a FST?

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

    The problem statement says that there will be 50 test cases and there were 50 pretests. So I'm presuming that there will not be any system testing for E

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

Curious to know if rating changes have been applied or not for this round. It is showing me as a unrated contest atleast for me when I tab the "all contests" dropbox in rating graph. Or this is a normal case when rating is not updated till now.

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

    It shows it as an unrated contest if rating changes haven't been applied. As of now, the hacking stage has just gotten over and the system testing still has to commence.

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

How to do Question E

If n<10^15 or number of queries < 60 my solution of ternary/binary search would have worked. My naïve idea= ask query as "? 1 m" . if this returns -1 decrease value of m or else increase

but this uses 60 queries. How to approach this types of question

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

    The issue with binary search is that you can only eliminate at most 1/2 of the search space consistently; in fact with question E I think there is no way to get a solution that you can be absolutely 100% sure is correct.

    There is a solution though that has about a 99.99% chance of being correct. It's only possible because of the problem emphasizing that one of two paths will be chosen with equal probability.

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

MikeMirzayanov is the only one without laptop in the picture.

Also I don't know the others. Does anyone else know all of them??

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

    It's the ITMO university team. Just read earlier in the post. There are seven in the team, but two are not in the picture (specified in the caption). I'm pretty sure the seven of them all know each other, and there are probably other people (possibly from ITMO University as well) that would also know them, but I'm not sure why you're so interested in them.

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

How do you realize when system testing is over in edu rounds and div3 rounds? At the end of hacking stage, it says "Final standings, open hacking phase finished". But don't system tests take place after this, in that case how is it final?

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

    System testing in these rounds usually happen 4-5 hours after hacking phase

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

      I am aware that system testing takes place a few hours after hacking. I am just curious as to how you realise whether sytem testing has finished or not. Like for round 820, what indication do I get to understand that system testing is done or not?

      All it says is "final standings" which isn't true I think because system testing hasn't started.

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

when will the ratings be assigned?

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

Why are ratings still not published, is this round rated or unrated

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

    This round had 12 hours of hacking phase, which will be used to re-judge all of the solutions as far as I know. The hacking round finished a few hours ago, now hacks are being analyzed most likely and after re-testing, ratings shall be published, so a few more hours probably.

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

I am having trouble with this, please share your insights.

  • What is your comment on the difficulty or standard of problem E?
  • Is it a good problem or an average one?
  • Can hard problems have such simple solutions? If so, can you give some examples?
»
20 месяцев назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Cool update. Would love to have these in future rounds as well :)

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

I think if this problem was placed in the A place,there will be more people solved it.Many people had the corret idea,but they think this solution is not fit to E problem.This kind of problems may be good,but where they should be placed is still a problem.

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

    Well, A through D are easier than E, so everything's fine, imo. And if it had been set as A, more participants would have been determined to dodge this round.

    I think we are forgetting, that this is a Div3 round. This E is even harder, than usual E Div3 problems, imo again.

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

When will the rating change? my rating has not changed yet

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

Problem F video editorial.

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

Finally ratings are updated :D

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

why is taking so long to update ratings? :/

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

G can be solved in $$$\mathcal{O}(m + n\cdot \log(n))$$$ time and $$$\mathcal{O}(n + m)$$$ memory, by using dp + segment tree.

First compute starting positions of occurences of $$$t$$$ in $$$s$$$. This can be done in linear time in many ways (I used z function). It's easy to notice that we can apply operations in order from right to left. Then, we will compute $$$dp_i$$$ = answer if the rightmost operation was applied to range $$$[i,i+m)$$$.

To compute $$$dp_i$$$, we could iterate to the left of $$$i$$$ on the starting index of the next operation (let's call it $$$j$$$). Two things need to happen:

  • If there is an occurence of $$$t$$$ in $$$s$$$ that is completely between $$$[j+m, i-m]$$$, it won't be covered by any operation, so $$$j$$$ is not valid. This defines a lowerbound on the value of $$$j$$$ (we can easily mantain it when increasing $$$i$$$ by using two pointers).
  • if $$$j+m-1 \geq i$$$, then $$$j$$$ is not a valid candidate, because given that we apply operations from right to left, the operation on index $$$i$$$ removed some of the characters of the occurence starting on index $$$j$$$. This defines an upperbound on the value of $$$j$$$.

This two conditions define a valid range of values for $$$j$$$. We just need to be able to combine the $$$dp$$$ values of this range. We can use segment tree to get this merged value.

Overall, we compute occurences of $$$t$$$ in $$$s$$$ in $$$\mathcal{O}(m + n)$$$ and then compute $$$dp$$$ values in $$$\mathcal{O}(n\cdot \log(n))$$$, so final complexity is $$$\mathcal{O}(m + n\cdot \log(n))$$$ with $$$\mathcal{O}(n + m)$$$ memory.

Here is a link to my submission :)

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

I solved 2 problems in this round but still, the rating is not updated. what is the estimated time it takes to update the ranking?

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

System Testing has ended way back.... then why so long in rating update?

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

Editorial section still not uploaded

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

I like E. Open my mind.

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

    I didn't. Even though the probablity is 50-50 still there's a chance that the ans for "? a b" is same as that of "? b a" for the first 50 queries. Change my mind :(

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

      Probability of all 50 queries failing and none giving an useful information is 2^-25, that's basically somewhat like 99.9998% chance of a solution passing.

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

        I don't get this. It fails for an edge case right. What if I'm the testcase author and I wantedly set such a case?

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

      Probability 0.00000003 is small enough to never happen, that's it

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

        See I get this but they've mentioned that the answers for the queries are pre-determined right so there is a chance that the solution fails for a case.

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

          No, answer is not pre-determined. It becomes determined only after you ask about this pair

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

          Or, if will be better to understand, they are pre-determined, but not with bare hands, but using a randomised algorithm, that randomly picks pre-determined answer for each pair. It is still the same task

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

I submitted this solution https://codeforces.com/contest/1729/submission/171912216 to the problem D yesterday during the contest, and after the system testing, it gave me a runtime error on test 7. In contrast, after system testing, I submitted the exact same code I submitted yesterday, to the problem and it got accepted. This is the link to that accepted solution https://codeforces.com/contest/1729/submission/172063331. You can check both the solutions are precisely the same line by line. So why does my code fail in system testing? MikeMirzayanov Vladosiya senjougaharin Gornak40 Aris Gol_D myav

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

    I do not run your code, but I think while(a[max1] >= 0 ) max1--; is dangerous. What if max1==-1? This causes undefined behaviour. I review your code on a mobile phone. Maybe I am wrong.

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

    Maybe thats the reason of ratings changing delay

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

    I didn't review it in depth, but considering the above comment, I suppose your code once slipped with out of bounds indexing, while another time it didn't. Might be because of the second time out of bound index still made sense(maybe bcs it was allocated at some other place where the resulting index was valid). You can try to send it again, you might get another runtime or might not, lol. Not sure what are the chances of the same happening again.

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

    This part will just keep doing max1--; while the value in *(a+max1) >= 0 even if max1 less than 0

    In the first time it worked because maybe the value in the memory just before a[0] is minus.

    in system testing maybe it was positive, so actually your code is wrong, and you are lucky that you got accepted 2 times.

    while (a[max1] >= 0){
            max1--;
        }
        max1++;
    
    
»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

After more than 24 hours and still no editorial.

and we still don't know whether this round is rated or not.

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

Plz, dont tell me this round is unrated... I am yearning to get expert D:

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

Pain

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

I only think that problem C have problem in descrption?????

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

    I don't think there is any issue with the description in Problem C. There was an issue with number of jumps vs number of visits, but this was corrected during the contest, and it was quite clear as to what was meant since the output specification required that the first value must be 1 (which is not a location that is jumped to).

    By the way, if you're wondering why your submission got Wrong Answer in Test 2, try the input string "baba". This is a common error from submissions that utilize sorting pairs. If the first character is smaller than the last character, then there is no problem, since you start from first instance of first character to last instance of last character in sorted order. But if the first character is larger than the last character, then you have to read in reverse. In this case, going backwards from the first instance of the first character will skip the later instances of the first character (if any). Ending at the last instance of the last character from a backwards sequence also means you skip earlier instances of the last character (if any).

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

Positive delta guys atm:

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

Waiting for cf round 820(div-3) rating update is like a deadlock!!

Study calling ratingUpdateChaking->
RatingUpdate checking calling TimeSpending->
timeSpending calling study ->
study calling ratingUpdateChecking

End of the day, waiting waiting waiting........


UPD : Rating updated

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

There has to be a good reason as to why can't I see editorials yet after 24 hrs

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

    Probably because it hasn't been published yet

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

      Why do you behave like a 4yr old?? You think this answer will help anyone??

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

        no, ur comment is dumb

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

        Sorry, I didn't mean to offend you, but is it really useful asking the same question over and over though there's no answer from the officials ? We'll get the editorial when it comes out and hopefully with an explanation for the delay and in the meantime, there's enough to do else.

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

patiently waiting...

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

Mike is starting to purge the cheaters so it should be rated very soon.

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

    A great initiative. I'd rather wait 1 more day than give 10 more contests to get my desired rating just because of cheaters.

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

      Are there really lots of cheaters? I'm a newbie, I thought they're not a common thing

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

        There are dedicated telegram groups of 4000+ members distributing codes during contest

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

          Ah.. well... It's kinda strange :0

          What's the interest of participating then? I don't understand...

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

          Once Codechef updated the ratings of a bunch of contests together after removing the cheaters. After removing the cheaters, i reached 4* rating which I never thought I will ever reach. So yeah lets be patient and let cheaters face the consequence.

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

When the rating will be updated?

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

I hope Codeforces team isn't kidnapped or something

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

    XD Ratings are up

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

      exactly after he wrote this comment ... something looks kinda sus

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

      What’s the difference between common standings and friends standings , common standings I have 3.6k ish rank while friends standings I have 4.1k ish rank Any idea ?

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

        In common standings you can see [trusted participants only] written at the top. To qualify as a trusted participant of the third division, you must: take part in at least five rated rounds (and solve at least one problem in each of them) do not have a point of 1900 or higher in the rating. Hence friends standing does not have this filter and common standings are after this filter. So, Rank in CS < Rank in FS.

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

Dear codeforces,

You have provided me with notice of copying but I found the code before the end of the contest on a youtube channel named cp rush.Below is the link to the video: https://youtu.be/TWG03knRpqM Also there could be many other people with same ideas and I did not cheat nor did I copied from any person mentioned in the mail. So I request you to take back the strike please.

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

    That's cheating, the video was published after the contest started. You basically copied a leaked code during the contest not cite an existing solution which was publicly available before the contest

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

Finally became a blue biscuit.
If I don't become CM in 6 months, I'll dunk myself in chai.

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

Thanks to this competition for making me an expert。

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

Автокомментарий: текст был обновлен пользователем Aris (предыдущая версия, новая версия, сравнить).

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

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

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

Hope everyone have a good mark!

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

why are arashjay?![user:arashj]