Автор awoo, история, 4 года назад, По-русски

Привет, Codeforces!

В Jan/29/2020 17:35 (Moscow time) состоится Educational Codeforces Round 81 (Rated for Div. 2).

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

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

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

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

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

Так же от наших друзей и партнёров из Harbour.Space есть сообщение для вас:

Hello Muscat

Привет Codeforces!

В качестве специального приза за Educational Round 81 мы разыграем бесплатные участия в Hello Muscat ICPC Programming Bootcamp, который состоится 19-25 марта (Оман) — полное покрытие оргвзноса, проживания и питания по системе «полупансион» на весь период учебного лагеря (но без перелёта). Путевки будут предложены топ-участникам, кто заполнил форму и соответствует условиям.

Условия:

  • Участие не менее чем в 10 рейтинговых раундах на Codeforces.
  • Максимальный рейтинг меньше 2400.
  • Еще имеете право принимать участие в ICPC и/или IOI.
Заполнить форму→

Всем удачи!

Мы также рады сообщить, что работаем с нашими партнерами над тем, чтобы обеспечить бесплатное участие (без перелёта) для команд, отправляющихся на финал ICPC. Если вы и ваша команда имеете право на участие в финале ICPC 2020, который будет проходить в Москве, заполните форму ниже, чтобы узнать, имеете ли вы право на бесплатное участие в "Hello Muscat ICPC Programming Bootcamp".

Подать заявку→

Поздравляем победителей:

Место Участник Задач решено Штраф
1 nickluo 6 177
2 KrK 6 184
3 NoLongerRed 6 185
4 Anadi 6 200
5 neal 6 204

Поздравляем лучших взломщиков:

Место Участник Число взломов
1 GiantTornado 58
2 rachit_raj 51:-1
3 harshraj22 41:-5
4 Ahmad__ 35:-1
5 MissTolochin 33:-2
Было сделано 1096 успешных и 873 неудачных взломов.

И, наконец, поздравляем людей, отправивших первое полное решение по задаче:

Задача Участник Штраф
A antontrygubO_o 0:01
B neal 0:05
C IgorI 0:07
D NoLongerRed 0:06
E Egg_Tart_Forest 0:14
F Combi 0:23

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

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

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

Educational Rounds always have good problems. Hope for a good contest.

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

Finally a contest ! Hope the gap between rounds will decrease

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

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

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

2f04e47240ec34bbe32.png

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

Petition to MikeMirzayanov to decrease the gap between forthcoming contests.

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

7 days is a way too longer gap.

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

Looking forward to interesting problems

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

vovuh are you the Vladimir Petrov who won IMO Gold in 2018?

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

I hope the statements will be short.

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

Lets hope that the frequency of contests increases.

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

Problems are difficult!

»
4 года назад, # |
Rev. 5   Проголосовать: нравится -33 Проголосовать: не нравится

B and C are difficult.

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

Even if the problem is not original, I think providing links to such problems and solutions during contest violates the CF round rules. Let us keep silence until the end of the round.

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

Finally solved the first problem. Heading for second. So much to learn...!!

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

I guess, someone accidentally swapped B and D :)

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

    D is easy if you know some number theory, but B is just casework, I don't think it's harder.

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

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

A Problem of APIO 2016:Boat

A harder version of problem F.

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

    I consider C as a problem which I've solved it before.Unfortunately,I couldn't remember it exactly while the round.Now I can get it.

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

How to solve D?

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

    Find g=gcd(a,m). Divide m by g, i.e. let f=m/g. Find Euler Totient Function value of f i.e. phi(f).

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

      Why?

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

        Okay, we know gcd(a, b) = gcd(b, a%b)

        So gcd(a+x,m) = gcd(m, (a+x)%m) and value of x lies between [0,m-1] that means possible values of (a+x)%m are [0, m-1] because (a+x)%m keeps on incrementing till it completes the full modulo cycle.

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

      do u have any proof ?

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

        Let's say gcd(a, m) = g

        We know gcd(a, m) = gcd(g*p, g*q) where gcd(p, q)=1 and (0 <= p < q). So we have to choose such x those satisfy gcd(a+x, m) = gcd(g*p, g*q). So we all have to do is find the number of co-prime of q those are less than q. So we have to call phi(q).

        sorry for my bad english...

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

          Thanks for your explaination. I still don't understand the final step. I am only able to get phi(q+a/g)-phi(a/g) by the above steps instead of phi(q).

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

            gcd(a+x,m)=gcd(m,(a+x)%m)=gcd(g*q,g*p) note that (a+x)%m will always be less than m and can take up any value from 0 to m-1. So finding phi(q) will suffice.

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

              Still didn't get it.Can you please elaborate more?I have the same doubt as twyc.

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

                What we think about should be (a+x)%m instead of a+x. So the range of answer becomes [0,m).

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

                  Okay, but how its ensured that all the numbers we get will be >=a,in phi(m/gcd)?

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

How to solve E?

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

    keep segtree on array where arr[i]=cost if you split at i, start by putting everything on the right and leaving the left empty, so arr[0]=a[0], arr[1]=a[0]+a[1]... then start by putting 1 on the left, then 1 and 2, then 1,2 and 3 and so on. when you put a new number on the left the cost for all splits with that number already on the left decrease by a[position[i]], the cost of all the splits without that number (the ones with i<position[i]) increase by a[position[i]]. each time get the minimum in range (0,n-2) (because you can't split at last element).

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

    Another segment tree solution that doesn't require range update/lazy propagation:

    Represent each segment by the triple $$$(suml, sumr, cost)$$$. Define the combination of two segments as follows: $$$A + B = (suml_A + suml_B, sumr_A + sumr_B, \min(cost_A + suml_B, sumr_A + cost_B))$$$ (this operation is not commutative, but it is associative)

    Start with $$$tree[p_i] := (0, a_i, 0)$$$. Iterate $$$i$$$ over $$$[1, n-1]$$$ by updating $$$tree[p_i] := (a_i, 0, 0)$$$, then grabbing the $$$cost$$$ value from the "sum" of the entire segment tree. The answer is the minimum $$$cost$$$ value retrieved.

    Explanation: Fix a split of the permutation to sets $$$L$$$ and $$$R$$$. $$$suml$$$ represents the sum of the costs of $$$L$$$ in that segment, likewise $$$sumr$$$ for $$$R$$$. Now consider how to combine the statistics for segments $$$A$$$ and $$$B$$$. Combining the sums is obvious, but what is $$$cost$$$? Consider there is a point $$$x$$$ within the segments where we want to move all points $$$i > x$$$ from $$$L$$$ and $$$i < x$$$ from $$$R$$$. If $$$x$$$ is in the left segment ($$$A$$$), the new cost is $$$cost_A + suml_B$$$, as we must move all members of $$$L$$$ in the right segment ($$$B$$$). If $$$x$$$ is in $$$B$$$, the new cost is $$$sumr_A + cost_B$$$ as we must move all members of $$$R$$$ in $$$A$$$. We thus pick the minimum of these two scenarios. The updates progressively move elements from $$$R$$$ to $$$L$$$ as the initial split. Be sure not to move the last element, or your answer would always be spuriously $$$0$$$.

    Sample: 69829539

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

Am I stupid? How do you solve D? I got to count numbers $$$b$$$ with $$$0 <= b < m$$$ with $$$gcd(m, b) = gcd(m, a)$$$ but made zero progress afterwards

Edit: As I look at my previous claim I realize that my proof in-contest is flawed. Does anyone know if the statement is actually correct? Looking at the solution given, my statement should be true but I am unable to prove it.

Edit: Just kidding, not flawed. $$$gcd(a, b) = gcd(b $$$%$$$ a, a)$$$ which easily applies to $$$gcd(m, a+x) = gcd((a+x)$$$%$$$m, m)$$$ since $$$a+x$$$ takes on m consecutive unique values, we know it takes on every integer $$$[0, m)$$$ exactly once.

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

    Let $$$d = gcd(m, a)$$$ and $$$m_1 = m / d$$$, $$$a_1 = a / d$$$, $$$b_1 = b / d$$$. Then $$$gcd(m_1, a_1) = gcd(m_1, b_1) = 1$$$.

    In other words, you have to count numbers $$$b_1$$$ with $$$0 \le b_1 < m_1$$$ which are coprime to $$$m_1$$$. This is actually an Euler function, $$$\varphi(m_1)$$$.

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

    Yes, but there is one more condition on b, that b >= a. It can be easily done by just altering the algorithm for calculating the Euler Totient Function.

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

    We can reduce the problem to couting the number of numbers relatively prime to m on interval [0..m/gcd(a, m)]. Let's say that m = m/gcd(a, m). Firstly you need to factorise m and store vector of unique prime factors. Then you can use the principle of inclusion and exclusion to calculate the number of such numbers that have common prime divisor with m.

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

    I've done it kinda differently compared to the Euler Totient guys here. Using the statement notations, we have a, m, and x. a = gcd*u and m = gcd*v, where (a, m) = gcd so (u, v) = 1 gcd must divide (a+x) so gcd must divide x therefore we have x = gcd*y

    Which brings us to an equivalent problem: find the count of y for which: (u+y) and v are coprime, where y is in range [0, v), aka their gcd is 1.

    For that, I used the principle of inclusion/exclusion because v had something like 12 factors maximum. And because I was in full blown panic mode and couldn't think of Euler.

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

      Can you explain your code how are you computing number of y's so that gcd(u+y,v)=1.??

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

        Do you know about the Inclusion and Exclusion Principle? I'll count the values of y for which the gcd will be different than 1: divisible with p1, p2, ... or pk, where p[1...k] are all prime factors of v. That's done with above mentioned principle: you basically consider all subsets of {p1, p2, ... pl} and you either add or remove their count from the result depending on the parity of its size. https://codeforces.com/contest/1295/submission/69761793 I'm hoping my code is actually correct, as in it doesn't fail after the hacking phase. It's really short once you remove the comments.

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

          Hey bro can you tell how is u + y == v (mod x), and what computation you are doing in your solve function after taking all the numbers from the set.

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

      Great minds think alike!

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

      Nice. But if the range of x is: 0 <= x < 2m Then Euler Phi does not work I guess. Like if a=8, m=12 and for 0<=x <m , The answer is 2 like Phi(3) but for 0 <=x <2m , answer is 4 i guess. Which is not Phi(3) but it is 2*Phi(3). Also if x was: 0 <=x <= 2m , Then the answer is 5. I don't know how to explain that. But if you see, for ==> gcd(a+x,m) = gcd((a+x)%m),m) (according to many comments) which says that no matter what is x's range, we only need to find the Phi(m/gcd(a,m)) which is incorrect for x's various range.

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

    How did you come up with gcd(m,a) = gcd(m, b). Couldn't understand this part.

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

      gcd(a+x,m) = gcd((a+x) mod m, m), so in fact you just need to check which remainders of m have the same gcd as a.

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

        we have to check no of coprime with m in range(1,m-1)?

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

          Not exactly, because you are looking for the numbers in range(1, m-1) which have the same gcd with m as a has (which is not necessarily 1).

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

    How do you make GCD (a, m) = GCD (b, m)

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

I'll bite, how to solve F? :P

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

GG, thanks for all the awesome problems! It was my first time participating in such a coding contest and it did take me some time to get used to many things on Codeforces. As a first-timer, Codeforces is like a gold mine to novice programmers like me xD.

Can someone give me a few pointers on how to improve as I found some questions quite challenging and there are always some nuts who can solve them in like 10min :D

Cheers~

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

How to solve C? My idea was to use hashmap (Key: Value being Char: List of Index) for characters of string S. But got TLE

»
4 года назад, # |
  Проголосовать: нравится -10 Проголосовать: не нравится
»
4 года назад, # |
  Проголосовать: нравится +95 Проголосовать: не нравится

It might be a very weird thing to ask as an author, but how to solve F?

It seems that my model solution is a lot more complicated that the ones from the participants.

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

      Thank you! It's amazing how the combinatorial approach to the problem can make the solution a lot easier. Unfortunately, I didn't even think about that, and the probabilistic way lead me to maintaining and interpolating the probabilities as polynomials (which is way harder, obviously).

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

Hi, can anybody make a hack? I receive an error after Hack button..

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

Did you really think this B was appropriate?

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

I just found a cheat in this contest;

At "Hacks" page of this contest. I found ma_da_fa_ka and InsaneNerd hacked each other on problem B. Since it's very funny, I looked into their solution and only to discover they copied each other and the both get accepetd in their latest solotion!

By the way, ma_da_fa_ka's code even didn't have indentation.

By the way, ma_da_fa_ka used bad word as his handle. (lol)

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

How do I know if D Euler(m / gcd(a,m) )

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

    Instincts....

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

    Let $$$d = gcd(a, m)$$$.
    Since $$$0≤ x < m$$$ and $$$1 <= a < m$$$, we easily conclude that $$$(a + x)$$$ mod $$$m$$$ can take values in the range $$$[0, m - 1]$$$ and we know that $$$gcd(a + x, m) = gcd(m, (a+x)\ mod \ m) = d$$$

    Let's look at the case when $$$d = 1$$$, let $$$b = (a + x)\:mod\:m$$$, our goal is to find all the values of b where $$$gcd(m, b) = 1$$$ which is by definition $$$\phi(m)$$$ given that we concluded earlier that b can take any value in the range $$$[0, m - 1]$$$.

    Now, let's consider the case where $$$d \neq 1$$$. Clearly, the values of b that we are looking for in the range $$$[0, m - 1]$$$ must be multiples of $$$d$$$, so let's enumerate all the $$$m / d$$$ multiples of $$$d$$$ in this range as follows: $$$ 1, 2, ..., (m / d)$$$. Let $$$i$$$ be the enumeration of the $$$i^{th}$$$ multiple, we want to count $$$i$$$ such that $$$gcd(i * d, m) = d$$$, but since $$$d \ | \ m \ and \ d \ | \ (i * d)$$$, we really want to count $$$i$$$ such that $$$gcd(i, m / d) = 1$$$, which turns out to be $$$\phi(m / d)$$$.

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

Problem is saying 998244353 decimal digits. What i was thinking number should be less than 998244353. Can anyone suggest what should i do to avoid such type of mistakes ???

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

Such a bug B!This round shoule be unr!

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

    Agree, I would have spent years trying to debug my solution if I did not decide that solving C first is a better idea...

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

how to solve B?

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

    You can create an array $$$cnt_0$$$ and $$$cnt_1$$$ in which $$$cnt_x[i]$$$ is the number of characters $$$x$$$ are from $$$0$$$ to $$$i$$$. Also, you can calculate $$$delta[i]$$$ which is $$$cnt_0[i] - cnt_1[i]$$$. Then, when the string is repeated again, the same pattern of $$$delta$$$ is going to occur but increased by a constant, because the number of $$$0$$$ and $$$1$$$ that you have from the previous string are accumulated. I'm going to concatenate $$$s$$$ two times to make the pattern visible.
    Let's analyze the following input
    $$$n = 6, x = 10, s = 010010$$$
    $$$cnt_0: 1, 1, 2, 3, 3, 4 | 5, 5, 6, 7, 7, 8$$$
    $$$cnt_1: 0, 1, 1, 1, 2, 2 | 2, 3, 3, 3, 4, 4$$$
    $$$delta: 1, 0, 1, 2, 1, 2 | 3, 2, 3, 4, 3, 4$$$
    Every time a string has finished, delta is going to change in a constant. Let's called that constant $$$d = delta[n] - delta[0]$$$. For each position $$$i$$$ between $$$0$$$ and $$$n - 1$$$, you know that you can reach all the numbers of the form $$$delta[i] + kd$$$, in which $$$k \geq 0$$$ because it is the number of times that the string is going to be repeated. So, for each $$$delta[i]$$$, $$$i$$$ between $$$0$$$ and $$$n - 1$$$, you have to check if it possible to obtain a non negative $$$k$$$ such that $$$x = delta[i] + kd$$$. The only corner cases are in which $$$d = 0$$$, then, if you have at least one solution, you are going to have infinite solutions of this form. Finally, check the case of the empty string if the solution is no infinity. The time complexity is $$$O(n)$$$.

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

    take '0' as $$$1$$$ and '1' as $$$-1$$$ and calculate the prefix sum $$$pre$$$.

    then for each $$$pre_i + x\cdot pre_n = balance$$$_$$$value$$$, if there is a non-negative integer $$$x$$$ satisfying the formula, add 1 to the answer. if balance_value is zero then add another 1 to the answer.

    if $$$pre_n=0$$$ then if there exists an $$$pre_i=balance$$$_$$$value$$$, then answer is -1; else answer is 0.

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

VERY VERY WEAK test cases for B :(

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

Author is fond of strings i guess.

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

D can also be solved with mobius function(Inc-Exc) 69790210. Let g = gcd(a,m). gcd(a+x,m) is g if and only if g|x. gcd(a+x,m) = gcd(g*c1 + g*y, g*c2) = g. gcd(c1 + y, c2) = 1. Use inc-exc now — neglect non-square free numbers for others if a divisor is prime product for even number of primes than subtract such numbers, for odd add them using the observation that if mu[n] = mu[d]*mu[n/d].

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

Anybody with a good hack for B?

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

How to solve C ?

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

I am not sure about my solution, can anybody hack my solution.

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

I am not sure about my solution,can anybody hack it.

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

that was one of the worst contest in all of the codeforces rounds. the problems were really bad. i hope to see better contest in future.

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

    why is it really bad? is it because you didn't do well in this contest.

    what a good contest for you would look like?

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

      for starters, a good CF contest wouldn't have more people solving C than B

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

        so what? the problems in edu rounds are equal (there are no points for problems, ICPC style). so solving C more than B is just a matter of swap. so people should see the number of participants who solve the problem and move to that problem. and being stuck in a problem is no good skill. people need to learn to move on.

        and even if the problems were given points and people solve c more than b, it does not yield the entire contest bad.

        you guys just talk trash about the contest while you do not know the efforts made to prepare the rounds. It is a lot harder to estimate how the contest would go for the participants.

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

          That might've worked if they had managed to prepare B well enough to avoid errors in the testcases

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

    Bruh salty. Edus are getting better ever since they reduced it to 6 problems.

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

    BRs82 was one of the worst person in all of the codeforces users.The comments were really bad.i hope to see better user in future.

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

Can someone explain the idea "phi value of m/(gcd(a,m))" for problem D? I mean how we got it?

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

    This has already been explained in previous comments.

    Let $$$gcd(a, m) = g$$$
    We have $$$gcd(a, m) = gcd(a+x, m) = gcd((a+x) \ \% \ m, \ m)$$$
    Notice that as $$$x$$$ increases, $$$(a + x) \ \% \ m$$$ will end up taking all values in $$$[0, m)$$$
    So we only need to find the number of $$$k \in [0, m)$$$, such that $$$gcd(k, m) = g$$$

    Since $$$gcd(ca, cb) = c \iff gcd(a, b) = 1$$$, we can take any integer coprime to $$$m/g$$$ and multiply it by $$$g$$$ to find a suitable $$$k$$$.

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

will there be points for successful hacking during the hacking phase?

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

69796073

Is it possible to see the hack case for my solution after preliminary result? I really have no idea of the counter example :(

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

I solved E without any range updation datastructure , just use map of values which have arrived and changes the current cost with coming elements and decrementing the cost if already added to the initial cost, it gives me wrong answer on testcase 10, can anybody look into it my submission https://codeforces.com/contest/1295/submission/69796456

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

Can anyone please tell me what is wrong with my code for problem B. https://codeforces.com/contest/1295/submission/69788305

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

A was very similar to 101612A - Auxiliary Project

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

What is "Unexpected verdict"? Hack #613188

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

    It means that one of the problem makers' solution is incorrect. (The official solutions had a different answer to each other.)

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

Didn't know much about such a nice function (Euler Totient Function)

Thanx to problem D for increasing my knowledge.

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

I think so many TLE codes are "accepted" in Problem C.

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

    A very simple testcase in Problem C was hacking testcase for many solutions.

    1

    aaaa....a(length is 100000)

    aaaa....a(length is 100000)

    If I woke up early, I could do more hacks.

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

      Why can such codes pass all the test data? Is all the test data random?

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

        Yes, Testdata is too week. But it is no matter, because this is an "Educational Contest" which is for not only algorithm ranking but also hacks ranking.

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

      I think if you hacked at least one problem with this test case, it might be added to final test.

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

Editorial please?

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

Am I the only 8ne who solved C with a precomputed DP

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

When will the system testing start?

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

where's the rating Lebowski

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

For question B: Can anyone explain why the output of

1
3 0
011

is 2 ? Please help, my solution is hacked and I don't know why

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

No matter how hard I try, I could not understand the solutions given for problem D. It would be great if someone could explain me how to do in simple and detailed steps. I would be really grateful to them.

Thank you!

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

    Let X be gcd(a,m),so gcd(a/X,m/X)=1.

    If gcd(a+x,m)=X,then (a+x)%X equals to 0,x%X also equals to 0.

    So gcd((a+x)/X,m/X) equals to 1.

    Find all the x in eular algorithm.

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

when will editorial be published?

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

Has the editorial for this contest been published yet? Or there won't be one?

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

expert in a one contest

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

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

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

problem A What's wrong in this?

include<bits/stdc++.h>

using namespace std; long long n; int main(){ int t; cin>>t; while(t--){ cin>>n; if(n%2==0){ for(int i=0; i<(n/2); i++) cout<<"1"; } else{ cout<<"7"; if(n!=3){ for(int i=0; i<((n-1)/2); i++) cout<<"1"; }

}

cout<<endl; }

}

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

    In your loop for(int i=0; i<((n-1)/2); i++), it should be i < (n — 3)/2 instead, as 7 takes 3 resources.

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

love the problems,short and easy to understand

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

Why is this solution so slow? (Problem C):

http://codeforces.com/contest/1295/submission/70937323

As for me, the complexity of this one is O(T*|t|*log(|s|))