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

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

Привет!

В субботу 23 июня в 18:35 (Московское время) начнется Codeforces Round #491 (Div.2). Раунд будет рейтинговым для участников с рейтингом менее 2100, остальные участники могут решать задачи вне конкурса.

Раунд во многом пересекается с задачами олимпиады по программированию ННГУ 2018 года. Если вы принимали участие в олимпиаде или дорешивали задачи, просьба не участвовать в раунде.

В задачах раунда вам нужно будет помочь студенту Васе справиться с трудностями, вызванными окончанием учебного года. Всего будет предложено 6 задач и 2 часа на их решение. Если же вы решите все задачи за 25 минут, то успеете посмотреть второй тайм матча Южная Корея — Мексика на чемпионате мира FIFA.

Разбалловка немного нестандартная: 500-1000-1250-1500-2000-2750

Выражаю максимальную благодарность Михаилу MikeMirzayanov Мирзаянову за всем известные платформы; Николаю KAN Калинину — за помощь в подготовке задач и координацию раунда; Михаилу mike_live Кривоносову, Алексею Livace Илюхову, Никите FalseMirror Босову, Андрею GreenGrape Райскому и Алексею Aleks5d Упирвицкому — за тестирование задач; Арсению arsor Сорокину — за перевод условий. А всем участникам желаю удачи на раунде!

UPD: Раунд завершен, всем спасибо за участие!

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

Div. 1:

  1. nuip
  2. krijgertje
  3. qoo2p5
  4. hohomu
  5. neal

Div. 2:

  1. King — решил все задачи, отличный результат!
  2. Daniar
  3. Saidjamol
  4. shoemakerjo
  5. Toki_Time-Tinker

UPD: Опубликован разбор задач

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

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

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

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

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

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

Why its not in the home page yet !!!!

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

Второй тайм матча Южная Корея — Мексика. Появилась еще одна мотивация сдать все задачи быстро.

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

!

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

Спасибо за контест в день Алых Парусов ^_^

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

Can't you push the contest start just 10 minutes? Give us Mexicans and Koreans a chance to watch at least the full first half. Finishing in 25 minutes is a little impossible btw.

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

will-know platforms??

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

statemnts ???

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

Кстати, если ставить контесты по утрам или ночам, они не будут пересекаться с матчами

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

Short task statement == Watch the world cup earlier

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

Round.id() % 100 == Contest.id() % 100

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

Solving all problems in 25 minutes (me) VS Scoring 1 point in 90 minutes (South Korea)

I'm seriously wondering which one is harder.

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

The RED coders can watch it easily. :)

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

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

CF + Fifa WC = just WOW

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

is it rated?

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

    "rated for the participants with rating lower than 2100"

    Copied from the blog!!! Please read carefully!!

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

during world cup : contests should start earlier (before matches)

i love this score distribution.

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

    If you continue to post this sort of stuff then soon your absolute value of contribution will be highest lol.

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

If you solve all the problems in 25 minutes you will be able to watch the second half of South Korea — Mexico at the FIFA World Cup.

This is the most interesting sentence I have over seen in Codeforces:)

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

We will reach soon Codeforces #500 !!

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

NNSU Programming Contest 2018 ??

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

Only Gods will solve all 6 problems and watch FIFA. XD

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

pls make extended registration I was not able to register

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

I wonder the time when problem 1000A appears.

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

Oh no! Queue again!

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

i just don't like the problems

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

    Me too, ABCDE looks too easy, and F is much harder than E.

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

why F must be such a shit

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

This really feels like Div3 except F which is Div1 :(

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

Worst contest I have ever written actually

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

Problem A is an extremely intelligent problem, it tests creative skills...

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

    did b,c,d,e wa at a twice. please explain A

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

      Sure, just write this...

      int grad = a + b — c; if (grad >= n || a >= n || b >= n || c >= n || n == 0 || c > a || c > b) cout << -1;

      For every WA I got, I added one more instruction with ||....

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

      I simply did this:

      A-=C

      B-=C

      if(A<0||B<0||N-A-B-C<=0) print(-1) else print(N-A-B-C)

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

    I understood DP with bitmask solution of problem E. But your solution had less time complexity. Could you please explain your solution?

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

      Sure! I use some sort of knapsack-like DP.

      Let frequency[i] be the number of times digit i appears in the input. I calculated DP[i][j] = in how many ways I can get a number of length j using only digits {i, i+1, ...., 9}.

      There are two cases:

      1. frequency[i] = 0. In this case, we obviously can't use digit i. So DP[i][j] = DP[i + 1][j].
      2. frequency[i] > 0. Here, I'm forced to use digit i at least once. Let's iterate the number of times I'll actually want to use digit i. I iterate this with a variable k which goes from 1 to frequency[i]. Now, I want to obtain length j, and exactly k digits are forced to be equal to i. We only have to decide in which positions will be those k digits. It's not hard to see we have j available positions and we have to choose k of them, so the answer is Comb(j, k), a binomial coefficient. We're left with j-k positios to fill using digits {i+1, i+2, ...., 9}.

      So we have DP[i][j] += DP[i + 1][j — k] * Comb(j, k).

      There is a special case when i = 0. Then, I won't be able to put a 0 on the first positions, so I'm only left with j — 1 positions to choose from.

      So DP[0][j] += DP[1][j — k] * Comb(j — 1, k).

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

Is it a better div3 contest rather than the previous two?

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

Is it a div3 contest rather than the previous 2 ?

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

2k accepted solutions for a D-problem during the contest, first time when I see something like this

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

    Yes, it is not very difficult, so it is only 1500 points comparing to standard 2000.

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

      anyway, this round trained solvers' speed so it compensated

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

Contest does not seem like div 2..!!

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

What is Testcase 7 for E?

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

one of the best rounds I tried thanks ashmelev

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

Codeforces Round #491 (Div.3)

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

    Exactly Bro.Though I wasted a lot of time proving that C can be done by Binary Search within the time limit.

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

How to solve C?

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

Who else felt that the author was talking about Messi in problem E :D ??

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

What a joke of a contest ! D is not a 1500 problem. Can someone prove that C lies within time bounds using a binary search ?

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

    Binary search is log. Check in bs: if at some step there are k candies, at next step it will be less then 0.9k. So check takes <= log(n) base 10/9 steps. Overall complexity is O(log^2).

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

    On day d, Vasya will have ((9/10)^{d-1})*n — k(1 + (9/10) + (9/10)^2 ... d times) = ((9/10)^{d-1})*n — 10*k(1 — (9/10)^d) candies. Make this 0 and solve for d, we see that d is logarithmic in n. So we can use binary search.

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

    Even if we assume that only 10% candies will be eaten each day(90% will be left next day), and Vasya does not eat any candy on any day, (10/9)^r * n <= 1 ( Assuming after r days candies left<=1 ) we need to find r, put n = 10^18(for worst case), you get maximum days (r = no. of days candies will last), which is <=500. So in binary search, this bruteforce takes <= 500 computations, so Overall it takes c*500*log(10^18) computations using binary search on k..

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

    Suppose k was 0 (it's obviously the worst case).

    Each day, we have n decreasing by 10%, i.e, it becomes . So after m days, it's . For n = 1018, something like m = 400 will bring this value down to below 10 — actually something a bit less, like m = 380 works.

    Having a higher k will simple accelerate this.

    Final complexity is O(log(1018) * 380), which isn't really a problem.

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

    in every iteration either

    which converges giving

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

Test 7 for problem E??

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

does D need dp ?

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

Float operations....we meet again -_-

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

    Actually no need in floats for B. You just check that 2 * sum >= 9 * n.

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

What is test 9 of problem F?

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

Last Div3 was harder than this.

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

DP round :o

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

What's the problem-C's idea? Just hate these kind of mathematical questions...

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

One of the worst contests I have seen. Maybe it is time for codeforces team to consult atcoder coordinators about how to arrange quality contests.

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

I feel so bad. Problems which have long code-time make me crazy (I am talking about problem E ToT). Problem E has not very much brainstorm, just long code ToT

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

    It won't take much time if you code in python... LOL

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

      It has nothing to do with python it's just that not many people know about variable level nested looping(even I didn't until today). So I guess at least I learnt something new from this contest.

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

        What exactly are you referring to? I used a recursive function for that.

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

          That's what I called variable level nested looping. In each level of recursion there is a for loop.

          The brute force way to do it would be to use 10 nested loops or so. I didn't know that it could actually be implemented easily with recursion until today.

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

            It's brute force anyway. It's called backtracking if I remember correctly.

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

        What's "variable level nested looping" ? Can u explain in brief?

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

    My code was quite short. Maybe because of the nifty macros http://codeforces.com/contest/991/submission/39568678

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

      "My code was quite short"

      Me: hmm, interesting

      "Maybe because of the nifty macros"

      Me: hmm, okay, let's see...

      "FOR(a0, 0) FOR(a1, 1) FOR(a2, 2) FOR(a3, 3) FOR(a4, 4) FOR(a5, 5) FOR(a6, 6) FOR(a7, 7) FOR(a8, 8) FOR(a9, 9){"

      Me: ... rotfl

      Actually I had an idea of doing just that, but couldn't make myself write such an abomination of all coding principles I've been taught to follow :) So, 23 seconds (yes, seconds! :) ) before the contest was over, I ended up getting AC with something way cleaner imho:

      http://codeforces.com/contest/991/submission/39577766

      Focus on "next_variant" function.

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

    c++ be like

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

    It does not have long code time, I did it in less than half an hour, and I'm not even a very good programmer.

    Read about recursive backtracking. It's a very useful technique when generating permutations or generating subsets of a set.

    I would suggest using competitive programming 3 (by Steven and Felix halim), chapter on programming paradigms, complete search. It also has exercises at the end of the section for each topic.

    That being said, in this problem, you only had to generate subsets, number permutations of one subset can be calculated using a combinatorics formula. (Check out my solution)

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

What is test 9 of problem C?

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

can anyone tell me whats wrong with my solution of problem C. i was getting wa on pretest 6. link to my solution — http://codeforces.com/contest/991/submission/39576641

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

    I was getting WA6, then added additional check for ans — 1, ans + 1, cuz binary search can give a wrong answer sometimes (well if implemented badly).

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

This is just sad. I used to participate in CF rounds to learn something new, but the past few contests have focused way too much on just implementation. Disappointed! :/

Secondly, this nowhere looks like a Div2 standard contest.

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

    You'd better take a look on the problemset than a contest... There are many good problems specially in sgu problems.

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

      I do solve problems other than contests, but IMHO a contest serves its own purpose.

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

    Secondly, this nowhere looks like a Div2 standard contest.

    How do you mean ?

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

      What I mean is, an average Div2 contest does not having the problems of this difficulty (I'm talking about D,E,F), and the AC solutions in this proportion.
      It looks more like a Div3 contest.

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

        Did you find all the problems easy ?

        I was very happy I got the binary search idea for C. I didn't think it was obvious. I wasn't able to do D, E and F :) Were you ?

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

          Well, I knew the algorithm for both C and E, but made silly mistakes while implementing it during contest (Got it for E, looking into C's bug)

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

Is there any hack against my solution for problem D, can someone please confirm? Code

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

Does any one think that this contest had difficulty of div 3 and previous div 3 had difficulty of div 2?

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

Completed E with 1 min to go and then remembered that I hadn't handled numbers beginning with 0.

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

How to prove monotonicity in problem C.I just tried, and I cannot figure out a proof.

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

    Let's assume that K is our optimal answer.

    We can prove that K+1 would hold good to get more than N/2 candies.
    Similarly, we can prove that 1,2,....,K-1 won't hold good. So it's like shifted unit step function (considering >=0 part only) if you observe carefully. And I guess, we can run binary search to find the starting point of that step.

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

    The amount of chocolates he collected at each turn monotonically decreases.Now, when vasya increases the value of k the rate of vasya collecting chocolates at each turn further reduces. Finally, total chocolates collected by petya in the end for a given n decreases with increase in k. Thus, chocolates collected by Vasya is also monotonic.This was my way to convince myself with a logical inference.

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

    I think it helps to look at it from Petya's perspective — there's still just one hole which I can't fill in though.

    Suppose, eating k candies daily, Vasya cannot reach , and the process takes d days. The candies Peyta gets are With k - 1, he gets

    Basically, with Vasya eating k - 1 each day, and taking into account that we're flooring, Petya gets at least as many as he does as when Vasya eats k daily. Now, if with k - 1 the process takes  ≤ d days, Vasya has less candies than he first did, so certainly not . If it takes  > d days, Petya has at least as many on each day as he had previously, so he ends up with at least as many as he had previously, which means Vasya can't have anyway.

    The only irregularity here is the last 9 candies — and even that disappears once d is high enough ( ≥ 9). Probably, that case can be worked out separately or something. Or maybe my logic can be modified a bit to take care of that, I'm just not seeing it.

    Edit: Small mistake in the numbers, fixed now.

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

can someone explain to me why 80 cannot be the number of the bus? 2028 has '8' and '0' both. I guess I have misunderstood the whole thing ._.

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

What could be the pretest 9 of problem D?

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

Task C, WA 8 anyone?

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

How to solve F ? i made an assumption that the optimal is either 1- take the number as it is 2- take a set of divisors and multiply them and for each number i used DP to find the minimum length to represent it, either : 1- its length 2- multiplication of prime factors 3- x*10^p + .....

However seems am missing sth or maybe buggy code :3

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

It was the worst round I ever took part in. Each problem can be solved by a monkey without creative thinking. To solve everything, it was necessary to have hands for realization.There was none idea problem. Also problem D should not be solved by 65% of participants.

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

    C required binary search idea. I don't think it's that obvious to beginners.

    I don't quite know how to do D, E and F :)

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

      I wrote this because I was very angry. I had found the solutions of E and F for 5 minutes after reading legend but didn't found the bugs in the code for an hour.

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

maybe, problem D needs a illustration i think:)

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

Instead of ranting at the level or quality of questions, spare some time to appreciate the efforts of the authors for conducting it. Weird how only handful of guys got all of them correct but almost everyone is lashing out here about the quality of problems.

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

    Tbh it's the difficulty of the questions which is low quality of questions is decent enough(apart from F which I don't know about).

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

      Can't complain when the contest problems were directly picked from some third party contest. The original problem setters were probably not aware that the contest will be used as a Div 2 contest on codeforces in future.

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

anyone else not satisfied with the difficulty of the round ?

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

Can someone explain how to solve E ?

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

    DP with bitmasks

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

    First, you can easily store the number of appearance of every digit.

    Let's calculate through every case that, in each, the number of used digit of each value (from 0 to 9) is either zero if there isn't any of such at first, or any positive value not higher than its initial appearance count. This could be implemented via backtracking.

    To calculate the value for each case, you need to know the number of distinct permutations and distinct permutations with leading zero(s).

    The number of distinct permutations is the factorial of the total digit count, divided by the factorial of each digit's appearance count.

    e.g.: with 2344, the number of permutations is 4! / 1! / 1! / 2! = 12.

    If there is no zeros in the case, obviously there would be no permutations with leading zeros. Otherwise, subtract one from the appearance count of 0, and calculate the number similar to above.

    The result for each case is of course, the number of permutations, subtracted by the number of permutations with leading zero(s).

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

      I did it this way too (hopefully no bugs), but it seems some people did bitmask DP? Can someone explain how that works?

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

        Basic outline is this:-
        Use your mask on digits of the number to determine whether you are picking that digit or not. Check if the masked digits contains all distinct digits that appear or not, and then find all valid permutations for the mask. To avoid recounting, you can hash the digits obtained in the mask and store it.

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

I was super proud that I finished 5 out of 6 problems! Then I took a look at Codeforces predictor and realized that at least 500 other people did as well and that my rating is probably going to go down.

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

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

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

I am not a big fan of criticising contests, but this is a bit too far. None of the problems require any kind of creative problem solving, being obvious applications of the techniques. (side note: "Obvious" is a strong word, but given that more than 600 people solved ABCDE, I think it is used properly). Given that more than 600 people out of 6000 solved ABCDE, this cannot qualify as more than a speed coding contest. For speed coding contests, I recommend the codeforces team not to give div4 problems to a div2 competition and mess our ratings, but to just redirect people to websites like typing.io or codefights.com :)

I do not think there is anything good to say about problem F. It was simply disgusting to say the least.

I do not wish to make anyone feel bad trough my comment, but this is the first time I actually comment anything negative on a contest announcement and I really feel it points out some issues that really have to be fixed.

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

    You are a Candidate Master. So, you may fell all the problems were easy.

    However, when programmers such as me solve C, we feel happy. Then reading comments like this telling that the problems were all very 'obvious' are demotivating :)

    I don't quite think C is obvious. The binary search idea is not obvious to beginners.

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

      I see your point. I clearly do not wish to demotivate anyone with less experience, that is for certain :) The problem is that this was theoretically a contest for all div2 users, but it certainly didn't act like one. A div2 contest should have problems that feel very easy and very hard, but this one certainly didn't have the latter. The only reason problem F had so few AC submissions is that it was a hard implementation problem. This might have been a very good contest for beginners but it definitely wasn't for more experienced users. In the same way that my comment may be sadly demotivating for "younger" competitive coders, this contest was for the good ones. It is horrible to be on #600 when you solved 5/6 problems and see your rating drop badly. Anyway, keep up the good work. One day these problems will seem "obvious" to you too, it is just a matter of experience :)

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

    I agree that problems were a little bit too easy but it is not right to compare this to a type race. I am sure that people did not come with solution in instants after reading the statements, competitive programming is also about proving things fast.

    For example in problem E I was hesitant to just "bruteforce" it, becuase it was not clear what was the complexity to me. But it turns out that the compexity is proportional to nd0*nd1*nd2*...*nd9 where nd0+nd1+...nd9=18 The worst case for this is when 18 is evenly distributed among ndi's, which means that the worst case is proportional to less than 2^10. Which is a cool proof to keep in mind I believe.

    Also if you did not solve problem F how do you say that it is disgusting? It may have a cool proof that you do not know about.

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

      imho F is an amazing problem. you could start with a really naive soution (that TLE's) then slowly prune the stuff you have to test.

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

      also this round is good for the majority of people (who normally solve the first two in a regular round then that's all). Here there's a better differentiation between a 1700 (who'll get 4-5) and a 1300 (who'll get 2-3). In many other rounds both the 1700 and the 1300 will get 2 problems and it's up to speed. So I think the speed aspect is much smaller here for most of the people, except for the tippy top.

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

Ughhh not a good round -_-

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

I solved E(pretests) using 10 nested for loops, is there any nicer solution?

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

    recursive

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

    dpmask — number of ways to place digits of n (mask < 2len(n))

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

    Not exactly... Maybe a recursive with the same idea.

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

    first count the occurrences of each digit from 0 to 9, Now take every possible combination of occurrences of each number such that each number occurs atleast once. now for each case it becomes a combinatorics problem to count possible no. of ways to arrange digits such that zero does not come on first place .

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

      But how to make every possible combination of occurrences for each number ?? I didn't got that.deepak1527

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

        you can do it recursively.

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

        It can also be done iteratively you can mask the occurrence of each number by first creating a prefix multiplication array of occurrences of every number is original number. Then masking them as occurence of 0 in current mask*1+occurence of 1 in current mask*pre[1]+..... Implementation of the idea- 39567146

        Upd: It failed systests. AC with very small change- 39603957

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

    Recursively

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

What's the test case 8 for problem E?

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

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

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

Amongst all the criticism of the round, I must say, problem A was hilarious xD ("BugDonalds", "Kilogramm", etc)

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

What's the test case 8 for problem E?

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

Reading the comments, feeling so stupid that I didn't solved C...

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

    Me too. Just solved 2 problems :(
    I am so baddd T^T

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

    Me too. For an hour I was trying to find a formula for (n, k), because I was sure that simulation is too long...

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

    Also Me....During Contest I Was Thinking of Formula To Solve Problem C...I thought That Simulation + Binary Search Will lead to TLE.

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

      i implemented a simulation for extreme cases, and it throws that it does at most 328 iterations or something like

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

Люди, почему в задаче С ответ 3. Если Вася будет брать по 2, то счёт будет 35 : 33.
68 — 66 — 60 — 58 — 53 — 51 — 46 — 44 — 40 — 38 — 35 — 33 — 30 — 28 — 26 — 24 — 22 — 20 — 18 — 16 — 15 — 13 — 12 — 10 — 9 — 7 — 5 — 3 — 1 — 0

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

    Счёт будет 33:35 в пользу Васи. 33 = 12 * 2 + 9.

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

    Применительно к k = 2 можем написать

        unsigned long long a, b;
        while (n >= 2)
        {
            a += 2;
            n -= 2;
            b += n / 10;
            n -= n / 10;
    
            cout << a << ":" << b << "\n";
        }
        a += n;
        
        cout << a << ":" << b << "\n";
    
    • »
      »
      »
      6 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Я уже сам такое написал, но спасибо что ответили. Считал руками, сбился при подсчёте двоек у Васи :-( Петю высчитал n — Вася и залет.


      ~~~~~ var n, vasya, petya: longint; begin n :=68; while (n > 1) do begin vasya := vasya + 2; n := n - 2; petya :=petya + n div 10; n:=n - n div 10; end; vasya := vasya + n; writeln('Vasya ',vasya); writeln('Petya ',petya); end.

      ~~~~~

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

          А чем плох Паскаль в данном случае? Рассматривайте это как псевдокод

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

            -

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

              Не понял, что вы хотите мне донести, я контест решал на С++, а тестовую программу написал на Паскале (у меня нет фантомных болей от него).

              Зато у меня есть РЕАЛЬНАЯ БОЛЬ от С++, в том месте, где сишка забывает проверить выход за пределы массива или строки, или подобном, Паскаль в этом случае более строг.

              Реальное преимущество С++ на контестах — STL. Хотя я вас понимаю, если в школе вы работали на Turbo Pascal. :-)

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

                Да ничего донести особо то и не хотел, просто пошутил.

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

                забывает проверить выход за пределы массива или строки Вы недооцениваете возможности C++.

                Думаю, эта статья будет вам полезна.

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

for F, does there exist a case where you need to do a^b * c^d ????

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

What is 8th testcase in problem F? I think it's (x >= 100) ^ y + a ^ b

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

The correct score distribution 750 250 750 125 1500 3000

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

    D was not that easy... It was really easy(the ones who did not take the case 000 000 when d[i] = 2 + d[i — 3] are stupid including me) but not easier than C man !

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

      There is very stupid greedy solution of this problem. I think it's really that easy. In C you actually have to think more than one minute.

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

        Why Stupid ??

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

          Well, there is 7 cases of positions of X:

          Spoiler

          each case have 1-2 lines of code inside, cases itself are simple to find. If you don't consider this kind of problem easy and boring, I do.

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

Whoever hacked my solution A will hopefully not live to see tomorrow;)

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

    You actually should be gratefull when someone hacks you. If your solution can be hacked, you most likely will get WA after the systests. But if you got hacked, you can fix your mistake.

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

      hm yes it helped actually, i fixed it though. wo so many downvotes silly joke chill people.

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

        I consider wishing someone to die not as a joke, not even close. I can understand black humor, if it's funny and creative, but this is just disgusting.

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

      He has to bear us XD.

      image

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

      I totally agree. My solution for problem D was hacked before 2 minutes of contest end. I somehow managed to fix the bug in last minute and got accepted. If my solution wouldn't have hacked, I would not even got a single point for problem D. Something is better than nothing. :)
      Sorry, for my poor english.

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

    Honestly, this attitude will lead you to nowhere, not mentioning the fact they were actually helping you out.

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

    Its good that someone hacked your solution as you still had time to correct you code which is definitely not possible during system testing.

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

It was one hell of an implementation_based round :O

Though they weren't bad problems IMO

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

The problems are kind of too easy for Div2 (except for F) . Thanks for preparing the contest anyway . It could be a very nice contest if F is easier and let D,E be harder .

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

"If you solve all the problems in 25 minutes you will be able to watch the second half of South Korea — Mexico at the FIFA World Cup."

Well I guess he wasn't joking after all! :D

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

In C, I got WA on 28th case. Please any one will help me, where I did wrong? code

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

    me too

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

    me too. Kindly tell me the reason once someone figures it out .

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

    ll half = ceil(N/2.0) ; this line might be giving precision error, I also got the wa verdict on this test case , now i changed my code to keep the count of both vasya and petya , it got accepted . :(

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

    It's better to check 2*val >= n rather than val>=half.

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

    ll half = ceil(N/2.0) ; is causing precision error for larger value of N (N > 10^15); for N = 999999999999999973; half should be 499999999999999987 but ceil gives 500000000000000000 using ll half = (N+1)/2; fixes this

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

The name of problem A is perfect :P

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

Was it really necessary to have 222 System Tests for Problem F?

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

Just wanted to share with you guys a nice way to solve problem E in Python:

http://codeforces.com/contest/991/submission/39579019

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

This contest was all about speed and accuracy. One WA and you are doomed.

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

    I think there might be other factors in it.

    I got WA in A incredibly early (and only got to solve it 1 hour later), though after solving 5 problems and got 2 successful hacks, my final standing is quite decent.

    A WA-verdict might not be the worst thing happened here — lose your morale and you are doomed.

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

I have been judged wrongly regarding question D.Bishwock for test case 16 It is showing that the correct answer is 66 and on runnning my code for the given test case, i am getting the answer as 66, but the status shows "Wrong answer on test 16". Please help!

Here is the link to my submission:

http://codeforces.com/contest/991/submission/39575936

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

well i don't see why codeforces have BUG/ERROR on judging solutions.here is the link to my solution to 2nd question http://codeforces.com/contest/991/submission/39564485 and at test case 29 i see no problem at all on getting answer 75. so why is it showing 76 there. i have rechecked it again and again.

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

    https://ideone.com/fNrNDf its same ideone submission is showing 75 answer

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

      ( 75*5+3*25 )/100 = 4.5. There is nothing wrong.

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

        so why it is telling me a wrong answer so who's fault is this

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

          using divide by n is a bit risky because it might give u 4.49999 instead of 4.5 I dont know if the same in happening in ur solution... but this happened for me .....

          Had a reaally bad contest tonight...

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

          its floating point precision issue. Instead of checking avg>=4.5 check 2*sum>=9*n

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

            So why its running perfectly on other platforms

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

              when you have something like 1.5 it may not be stored exactly as 1.5. some systems take it as 1.4999999999 others have it as 1.50000000001 so that tiny change might result in completely different output and which one happens is compiler dependent. So it's a good practice to never use floating point numbers unless it's inevitable.

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

Never use Python round function ever!!!! It F**KS you bad. Got WA in main tests for 2 questions(B and C) and I have learnt my lesson. Just avoid.

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

    never use round function in any language. even better never use floating point numbers unless it's inevitable.

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

I do not get the hate against the setter. It was clearly mentioned it had an intersection with some other contest and the problems might have been taken from there. Even if not, if someone has a problem then I would love to see a contest from them.

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

    If you blame a cook for cooking bad food that doesn't mean you can cook better than him it means that he didn't do his job properly.

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

991C - Candies

for Test case #7: Input: 999999972 Jury's answer: 39259423

My exactly same submitted code is giving different output on CodeForces and IdeOne.

CodeForces: 39581649 Output: 39259426

IdeOne: ideone Output: 39259423

ashmelev Can you please check?

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

    It seems that problem is in float type which handles big integers poorly. Probably exact precision is compiler-dependent; anyway I recommend you to avoid non-integer operations in such problems.

    Just replace

    if (k * days + m >= ceil((float)n / 2))
    

    To

    if (k * days + m >= (n + 1) / 2) 
    

    and you will have the correct answer.

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

Will this contest have tutorial?

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

In C, instead of m = (lo + hi) / 2, I wrote m = floor((lo + hi) / 2.0), but my submission gave tle for n = 1000000000000000000. When I tried to find out the reason, I figured out that for lo = 39259424579862569 and hi = 39259424579862576, m came out to be = 39259424579862576. Can anyone explain the reason for this ?

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

    Send your code. I think, you forgot next string: value=constant.

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

    It is due to the ceil and floor functions being so slow! Check this submissions : 1 2. The only difference here is in ceil function. I generally try to avoid ceil and floor function now! I found a discussion here but am unable to get it. It would be great if anyone can explain some concrete reason behind this.

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

      I think you misunderstood my problem, I tested it locally by printing the values of lo and hi and found that for the value I mentioned in my comment at the top of this discussion, m was coming out the same as hi and so hi was not decreasing at all. That was the reason for tle.

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

Is it just floating point precision issue that :
39569964 got WA and
39589278 got accepted ??

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

In B, I got WA on 18th test case. Can anyone explain what is wrong with my code? I can't understand I got correct answer on other online IDEs. here is my code http://codeforces.com/contest/991/submission/39556881

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

    Here is the AC version of your code: 39603674. The WA was because of precision issues with floating point numbers, which relates to the way they are stored in the memory. Rather than directly comparing them for being less than 0, it is a good practice to check that they are less than a very small value like 1e-9. Because of the way they are stored, a value that is very very small and can be treated as a 0, might compare greater than 0, so it is better to compare them to a smaller value and not 0. I have even seen some compilers giving warning msgs when I tried to apply comparison operations to floating pt numbers.