Автор awoo, история, 5 лет назад, По-русски

Привет, Codeforces!

В 28.12.2018 17:35 (Московское время) состоится Educational Codeforces Round 57 (рейтинговый для Див. 2).

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

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

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

Задачи вместе со мной придумывали и готовили Роман Roms Глазов, Адилбек adedalic Далабаев, Владимир vovuh Петров, Иван BledDest Андросов и Soroush Tabesh Soroush.

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

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

Место Участник Задач решено Штраф
1 chuochuo 7 222
2 Traxex_ 7 270
3 quailty 7 281
4 hitman623 7 285
5 E.Space 7 316

Было сделано 69 успешных и 296 неудачных взломов. Пожалуй, в этот раз обойдемся без таблицы, слишком уж она нерепрезентативна)

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

Задача Участник Штраф
A irkstepanov 0:00
B ChiIIi 0:03
C Qing_Yang 0:06
D aleex 0:07
E chuochuo 0:57
F isaf27 0:19
G 300iq 0:06

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

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

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

ggguys i cant wait! !=) X) :)

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

Second last chance to reach my 2018 rating goals lol.

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

hello gays i live in a very wealthy part of the austro hungarian empire and i am wondering if the contest will be worthy of my royal time i request you inform my intelligence on whether the contest will be rated or not

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

However,I love Educational round.

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

YESSS...a div2 round for candidates ;)

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

I hope it would be a great educational

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

Hope I can become hahalmao555huehuekkkxixi after the contest.

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

Today I'll become a Christmas mandarin orange.

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

Nickname?

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

One interesting thing in this contest is that both the description and problem name of problem G greatly resembles Problem D in XVIII Open Cup, GP of Urals. But the solution differs a lot, and actually, the solution to that Open Cup problem is more similar to Problem E of this contest. That's why I think the problem difficulty of E,F and G in this contest should be rearranged, with G being extremely trivial once you know FFT, F being some simple calculation once you know the linearity of expectation, and E needs some combinatorics knowledge(like counting in a multiset and inclusion-exclusion principle). And the number of accepted solutions seems to prove me right.

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

Problem F reduces (at least I reduced) to calculating this sum in small complexity:

for given x, y, m.

Any hints to calculate this?

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

    LOL, LMAO, ROFL. No, it's not solved like that.

    Normal solution: there are three kinds of inversions:

    1. Inversions between known elements — they are calculated by your favourite method (Fenwick / mergesort)
    2. Inversions between unknown elements — if there are P unknown elements, they form P*(P-1)/4 inversions due to symmetry
    3. The last case is when one element is known, and the other is unknown. Let the known element be x, and there are some free places to the left and some free places to the right. For each of free left places, there is an inversion if you put element > x there (find count of these elements by lower_bound). For each of free right places, there is an inversion if you put element < x there (find count of these elements by lower_bound). And the rest is easy.
    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится +38 Проголосовать: не нравится

      LOL, LMAO, ROFL. No, it's not answered like that.

      My question is about calculating the sum not how to solve the problem. Anyways, thanks for the solution :P

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

        This is a valid method of calculating the sum in reasonable complexity though, given that it reduces to the same thing (differing by some easy-to-calculate value). You're just counting the same thing in different ways and equating them.

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

        I think you have already figured out how to solve this problem, my reply is too late. :P I was trapped in the same calculation as you. However, after peeking others' solutions, I found it better to calculate the expectation alone, rather than calculate P and Q separately. This problem enlightened me a new angle to calculate expectations. When it is the case that P is hard to calculate, we may try to calculate the expectation directly. Good luck!

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

    First idea and very overkill is next: let and , then your sum is coefficient of zm of a convolution A × B or something like this (if you calculating with modules). Convolution FFT.

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

      If you write A and B in closed form as follows:

      A = x·z·(1 + z)x - 1

      B = (1 + z)y

      and then multiply them, then coefficient of zm in A × B = x·z·(1 + z)x + y - 1 would be simply x·C(x + y - 1, m - 1).

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

    Does anyone know why my nlogn solution is timing out?

    https://codeforces.com/contest/1096/submission/47665224

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

      It might be because my distance is linear...but I also tried with Fenwick tree, and still.timeout

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

It's guaranteed that rating of this topic will never exceed 998244353 (by absolute value).

(OK, it's not really)

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

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

number 998244353 everywhere

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

How to solve G? Is it some sort of bruteforce on small strings + DP? Couldn't figure out the details in time.

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

    Trivial when you know how to accelerate polynomial multiplication using Fast Fourier Transform.

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

      Can you elaborate a bit? Specifically, what are the polynomials you're building and then multiplying? Thanks!

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

        Let polynomial f(x) = a0 + a1x + ... + a9x9, where ai = 1 if i is an available digit and 0 otherwise. Then the answer is sum over the square of every term of f(x)n / 2.

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

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

How to solve B?

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

    Count length of prefix and suffix such that all characters in the prefix/suffix are equal.

    if prefix == n, answer is n * (n+1) /2

    if first char == last char, answer is (prefix+1) * (suffix+1)

    else the answer is 1 + prefix + suffix

    Edit: first case won't happen

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

        It is wrong due to overflow of int ans. Replace itwith long long, it will be accepte.

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

      I think the first case won't be used, as its given in the question that there are at least 2 distinct characters.

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

      can u tell me how u derive the 2nd case?

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

        First char == last char means you have a string that looks something like aaabcaaa

        Any way that you split the string will work if it excludes the 'bc'. Consider this:

        |a|a|a|bc|a|a|a|
        

        Choose two bars, one of left of bc, one on right — that represents a substring that you remove. Note that there are p+1=4 bars on each side, p being number of a's on each side. Because you are taking one from each side, the answer is (prefix + 1) * (suffix + 1)

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

      How do you derive the last case?

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

        Say you have this:

        |a|a|a|cc|b|b|b|
        

        Each bar to the left of the "cc" represents a substring that you can remove (from the bar to the right). Each bar to the right is a substring from the bar to the left.

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

      [user:goloins] can you please tell the answer to "aabee" ??/according to conditions mentioned by you answer should be 5 but it is coming 7!!! I may be wrong..hopefully you can point out my mistake

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

        The answer should be 5. The resulting strings are "", "a", "aa", "e", "ee"

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

is this eduround 998244353?

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

What was wrong with C? I messed it up :(

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

Am I the only one who stupidly thought B answer is x*(x+1)/2

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

Is D f(i,j) = min ans for prefix i such that starting j letters of hard are taken.

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

    i don't know, but my solution is this rsrs.

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

    Yeah, that dp should work.

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

      I could be missing something obvious but I don't understand why that dp works ? Could you please explain ?

      EDIT: Maybe I just dont understand what "starting j letters of hard are taken" means here. Could someone just elaborate on that ?

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

        Minimum cost we can obtain from prefix till index i such that the resultant subsequence contains first j characters from string "hard" in order. Then you can do DP : 47674309

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

I got WA on test case 4 for problem D, does anyone know what could be wrong 47654263

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

    Me too :( 47654227

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

    Test 4 catches a lot of bugs; from a quick scan of your code, it seems like you made the assumption that the solution must be removing all the occurrences of one letter. This isn't the case. Consider if the string is "harard", where the first a and the last r are very cheap to remove, but everything else is very expensive. Removing those two letters would be the solution.

    The general problem is solved using DP.

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

the solution for C for god sake?

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

    Multiple of pi(180) which is multiple of alpha angle. Also check that internal angle obtained is greater than or equal to alpha angle.

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

    for every side length k from 3 to 360:

    smallest angle = 360/(k*2) biggest angle = 180-360/k

    every angle in between is a multiple of the smallest angle. If the angle you're being asked is between the smallest and biggest angle and it is a multiple of the smallest angle, then the answer is k.

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

      please tell the proof regarding "every angle in between is a multiple of smallest angle"

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

        Imagine the polygon as a circle with points on it.

        The inscribed angle theorem relates length of curve to the angle. https://www.mathsisfun.com/geometry/circle-theorems.html

        The smallest angle represents the arclength between two adjacent points, and every possible angle represents the arclength of some integer * the smallest possible arclength.

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

        essentially any regular n sided shape can be placed inside a circle. any angle is the sum of the different smallest triangles that divide up the shape around an arbitrary point. circle geometry states that because some of the angles subtend equal arcs/segments then the smallest angles must also be equal, and hence any angle formed must be a multiple of the smallest angle

        edit: ok you responded by the time i send this.

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

      How did u came to the conclusion that all angles in between are multiple of smallest angle?

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

    I've solved it and here is a link to my solution: https://codeforces.com/contest/1096/submission/47665926

    You may want to read below to understand it.

    EXPLANATION:

    It's a property from grade 10 (high school) maths.

    If you draw a circumscribed circle around the regular polygon, the angle subtended (by any two vertices/arc) at the centre of the polygon will always be double of angle subtended anywhere on the circle.

    Here is a youtube link if you want the proof: https://www.youtube.com/watch?v=MyzGVbCHh5M

    ============ Steps ===========

    1) The input needs us to find a suitable "n" for a given query angle "q". What we do is find suitable "n" for angle subtended at the centre of the circle. which is 2* q.

    2) But how do we find "n" ?

    Total angle subtended at the centre of a circle by any two vertices can be a max of 360 (to be precise, some decimal value < 360). Hence if you have "n" vertices, you can "distribute" this 360 between the vertices.

    What I mean by that is that if there are 10 vertices, then every 2 adjacent vertices will subtend 360/10 (=36) at the centre.

    To find "n", we need to use a loop , eg: for(n = 3; n <= 360; ++n) Start from n = 3, so that you can get minimum "n" once below condition is satisfied. On finding it, break from the loop.

    // NOTE: For this problem, "360/n" must also be an integer. Hence you must // ignore values of "n" if "360 % n != 0"

    if( (2*q) % (360/n) == 0 ) {

    // found n. 
    //Break from loop if you have structured your code that way.

    }

    This condition means that if our required subtended angle (2*q) is a multiple of the minimum possible subtended angle for a given "n", then we have found "n" (there is an edge case, see Note below)

    =======

    FINAL NOTE: There is an edge case in the sample input and output given in the problem statement, the 4th input (178) has output 180, and not 90. this is hard to explain in words but much easier to understand visually. I have commented about this in my solution (linked above) as well. Please see that comment and try drawing it out if you don't follow.

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

What's test case 3 in C?

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

Did someone get AC on G with FFT (not NTT)?

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

    Not even with TNT man.

    that problem is really hard.

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

    neal did it 47640712

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

    I did it. To avoid precision error, I used the well-known technique that decomposes each integer into two parts. Calculate both on the real and imaginary part to reduce some factors. Basically, it's the template that tourist uses, very well-implemented and works with arbitrary modulos.

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

These guys are really good :D

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

    Is it that you didn't read problem F and G, or just that you're too weak to learn how to solve them?

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

This user is hoax and the person who hacks his solution needs to be reported or taken down !! https://codeforces.com/profile/problem_destroyer420 Returns 0 for a particular n and voila hack from another id !

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

C had a nice corner case and D was a nice problem in general. Enjoyed the problems, although it seems difficulty for tail end of problems was slightly mis-estimated.

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

awoo

https://codeforces.com/contest/1096/submission/47652681

What is wrong with this? In my compiler it shows correct!

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

    The output is just different... if your compiler is not giving the same answer you should make sure they are consistent but I feel it may just be you not looking closlely

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

      Please check in yours. Then you will see

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

        Ok, I got 18 on my compiler too. We must both be using a compiler not like codeforces. The only difference I can think of is the way division happens, with your code, a slight difference could cause floating point errors. If you don't use any doubles you may be able to get the right answer (and it is better to not use doubles anyways, it will likely break on later test cases even with your compiler)

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

          I don't care cf compiler. Make me expert MikeMirzayanov!

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

            You should take care of precision errors. int(x) is a bad way to round a double, since if you get 0.9999999 instead of 1.00000, int(x) returns 1.

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

              what is the best way to round-off whenever needed? Is (int)(floor(x)) always fine?

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

                Firstly, it's always better to work with integral datatypes if it is possible.

                And secondly, (int)(floor(x)) is bad because of the same reasons. Typically (int)(x + EPS) works well, where EPS is somewhere around 10 - 9, provided that x is non-negative.

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

            Maybe your code isn't so robust. Please avoid using doubles if possible. Actually, I think it more important for you to learn how to solve it without doubles. Good luck at Goodbye 2018! Wish you expert next time.

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

Fake hack: applese hacked __123456__'s submission to problem A. It has a special if for failing on purpose:

https://codeforces.com/contest/1096/submission/47640777

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

I got WA on test 4 for problem B, does anyone know what could be wrong 47654945

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

How to solve D?

I assumed that it is optimal to delete only one type of character. Is this assumption incorrect?

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

    DP[i][j] = minimum cost to delete the first 'j' characters of "hard" from prefix i.

    That assumption is incorrect.

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

On problem G. I used Divide and Conquer + polynomial multiplication ,but get TLE However, if someone had used dft & fastpow & idft , he would have AC

My IQ is not enough to figure out the second way(it's 23:30 in China), but these two ways have the same time complexity O(nlogn)

Although I think it is ok not to let me pass, but I'm very sad. With this problem I would become Orange(my current rating is 2097)

TAT

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

    It's just the issue with constant. Well-implemented FFT can pass,too.

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

    D&C + polynomail multiplication is .

    Or did you use some special version of D&C?

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

      No. With the equation , you can see that . Same complexity with polynomial inverse/exponentiation/logarithm and some other operations.

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

        In D&C it's , if it's implemented just like ''divide the segment into two, solve recursively and then combine answers with polynomial multiplication''.

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

          Yes. But here we are exponentiating a polynomial, and we only need to calculate one half, and the other half is the same, and thus the 2 factor is gone. You can implement it use fast exponentiation just like exponentiating integers. Time complexity is .

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

Problem F is similar to SRM 470 Division 1 — Level Two

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

I want to check if my code is wrong, so I hack myself.
I write a program in python3 to hack problem C:

print("180")  
for i in range(1, 180):  
    print(i)

but system said "Validator 'val.exe' returns exit code 3 [FAIL Unexpected end of file — token expected (stdin, line 181)]", can somebody help me to solve this problem?

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

For problem G, could someone provide an explanation of how to deal with MOD in fft?

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

How can someone hack problem C if they have included all possible values of angle in pretest #3?

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

To problemsetters, G is definitely a cool problem. However, do you really think it is suitable for contests rated for Div2? This problem could be easily solved by just copying FFT templates. I think this not fair to the newcomers who has problem solving skills but didn't know much algorithm yet. I think putting these kind of problems in the problemset will cause the rating to be less accurate.

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

    Even though ERs sound like regular Div2 and behave like regular Div2, we (authors) still believe that it's not a regular Div2. That's why we allow ourselves more freedom in using "well-known" ideas (but still trying hard to find a balance).

    Of course, it will lead to some disturbance of ratings, but it's a thing we should deal with.

    On the other hand, if newcomers wouldn't confront new for themselves but famous in community tasks, they will not learn them. And I think, ER is a perfect place to meet with such tasks.

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

      I agree. If it wasn't for educational rounds, this task would not fit anywhere on Codeforces. It's too easy for Div 1 D/E, and putting it in a regular div2 round seems strictly worse than putting it in a educational round.

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

In problem A, in the output format it is clearly stated that the answer in the i-th line should correspond to the i-th query but I just saw a submission who has printed l and 2*l in seperate lines but the verdict is ok. Is it actually fine to print it on seperate lines?

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

It be like that sometimes. F

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

please stop making contests

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

How to solve F ? Or atleast is there a way to find total number of inversions among all the n! permutations

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

    It's just . Use the linearity of expectations.

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

      Ok. I now googled and Got it for no of inversions for n!. Any how thanks for replying. But how is that n! * n * (n-1) / 4 ? Can you plz show me the proof or method of deriving it ?

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

        For a single random permutation, 0 inversions is the best case, n*(n-1)/2 is the worst case. Due to symmetry (you can remap i -> n-i+1), the expected value is n*(n-1)/4

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

        For every permutation, you can take it along with its reverse permutation. Every possible inversion happens in either the permutation or its reverse. This implies that the average number of inversions is n * (n — 1) / 4.

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

how to do C?

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

    Handle ang = 179 separately, n= 360;
    (This is because for every angle less than 179, we can attain it using a polygon with no. of sides n <=180)

    For other values of ang:
    Start with no. of sides s = min(3, ceil(360/(180-ang)))[This checks if the minimum angle possible in the polygon is greater than or equal to ang ] This was derived from, angle of a regular n-gon = (n-2)*180/n;

    Now we need to satisfy,
    i*ang == j*180; (for some s<=i<=180, and j<i)
    (Idea behind this is: ang/180 == j/i; ie "ratio of ang to the total angle of a triangle" should be equal to the "ratio of no of sides opposite of ang to the total no. of sides of the polygon") This can be done by brute-forcing on i and j;
    Thus complexity is O(n^3).
    Here's my submission.

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

    Let t = gcd(180, ang). Result will be  - 1 if ang = 180, if , otherwise

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

When you have no idea for C, so you decide to build regular polygons and check all angles between them until you've precomputed the answer for all angles...

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

Peace on You All :D

I Have a question in "D" Problem .. Why my Greedy Solution is Wrong ?Here

The Idea Is ,

If i delete all character ( 'h' , 'a' , 'r', or 'd' ) it will be impossible to get subsequence = "hard" is that right ? but this is not the all answer the rest is coming

this is how i choose characters to delete character "d" i delete if there is a subsequence = "har" before .

character "r" i delete if there is a subsequence = "ha" before and i will walk to last "d" i choose to delete .

character "a" i delete if there is a character = "h" before and i will walk to last "r" i choose to delete .

character "h" i delete and i will walk to last "a" i choose to delete .

and i will print the Minimum of all that . Why This is Wrong !

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

    I think my solution is similar to yours, however, I find the greedy solution will not work for the following case: "harard", [100, 1, 100, 100, 1, 100]. The minimum cost is 2 when you remove 'a' at 2 and 'r' at 5, and the result string is 'hrad'. It takes me a long time to figure out this, I'm still working on understanding the DP solution after checking the accepted code from others...

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

In problem C, that line print −1 if there is no such n made me question myself a several times.

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

I have no idea how to solve C , can anyone help how to solve ?

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

so much math ._.

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

I think ideally, an accepted problem C cannot be hacked nor fail main tests. As the pre-test 3 checks all possible 1<=ang<=179.

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

In what complexity should E be solved? My O(N*S*2) solution doesn't pass.

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

can someone explain intuition behind D? i tried some people's solutions and coded them but i still don't fully understand them.

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

i don't know why the answer of task 178 is 180, but not 90 on problem C!!!

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

    It is true that you can form angles in increments of 2 with a polygon of size 90. However, the max angle you can form is 176 ((n-2)*180/n).

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

    Build a regular 90-gon and try to find out yourself lmao.

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

when will you provide tutorials

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

what meme around number 998244353?

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

    Needed for NTT, one of the solutions for problem G. Specifically, NTT needs that your prime modulo be off the form n*2^k +1. That mod fits. Presumably, they used it through the whole contest to not give too much away.

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

Can anyone explain the logic of D?

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

    dp[i][j] is minimum ambiguity when we are at prefix j of string "hard". So,we are at state (i,j) and in next index (prefix j+1) comes, we have two choice, either to remove that letter or continue without removing(increasing prefix) and in next index any other letter arrives,we will be in same state. hence transition will be if(next index is next character after j) dp(i,j)=min(dp(i+1,j+1),dp(i+1,j)+a[i+1]) else dp(i,j)=(dp(i+1,j)).

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

when will be the editorial released?

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

How to take random result in problem A ???

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

    just print(ans, ans*2)..that's enough since it is the best case and the problemsetter said that it is guaranteed that the answer exist

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

Can you explain the algorithm of C??

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

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

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

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