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

Привет, Codeforces!

В Apr/26/2020 17:35 (Moscow time) состоится Educational Codeforces Round 86 (Rated for Div. 2).

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

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

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

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

Отдельное спасибо Михаилу darnley Дворкину за помощь в подготовке раунда!

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

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

Codeforces and Harbour.Space

Привет, Codeforces!

Вы сделали это! В прошлом Educational Round у нас было рекордно высокое участие — 21750 человек! :) Мы рады поддерживать такое удивительное сообщество, и с нетерпением ждем увеличения этого числа в будущем!

Мы ищем бриллианты — активных, талантливых людей, увлеченных технологией и дизайном, вне зависимости от национальности, пола и культурного происхождения. Мы понимаем, что бриллианты не появляются сразу ограненными, поэтому наша миссия заключается в том, чтобы выявить и поддержать как можно больше талантливых молодых людей, с тем чтобы они могли реализовать свой потенциал и обеспечить будущее, которого они заслуживают.

Если Вы заканчиваете обучение или уже получили степень бакалавра, мы ждем Ваших заявок на получение полных магистерских стипендий по ссылке ниже.

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

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

Место Участник Задач решено Штраф
1 DreamLolita 6 211
2 KrK 6 235
3 Sugar_fan 6 259
4 krijgertje 6 268
5 Temotoloraia 6 272

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

Место Участник Число взломов
1 liouzhou_101 81:-35
2 j_peters 29:-16
3 eR6 18:-19
4 tonyli00000 14:-15
5 phyzzmat 8:-7
Было сделано 281 успешных и 925 неудачных взломов.

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

Задача Участник Штраф
A sevlll777 0:00
B Aerosmith 0:02
C DreamLolita 0:03
D xb0nS 0:14
E AaParsa 0:17
F chemthan 1:07

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

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

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

Kudos. " You really went for it in the last Educational Round! We had an all-time high participation of 21750 people "

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

Lets cross 25000 this time!

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

Can someone please explain what's a difference between codeforces educational and normal rounds? Thank you.

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

    You can find following difference

    1. Normal codeforces round has a variable points for each problem(500,750,1000 and so on). Each problem has equal points on educational rounds.

    2. In normal coforces rounds you can hack during the contest, in educational round there is 12 hours hacking phase after contest is finished.

    3. Normal codeforces round has 20 penalty for wrong submission where educational round has 10 minutes penalty.

    4. During contest successful submission gives verdict pretest passed where educational rounds gives accepted.

    5. Normal codeforces round judges your last pretest passed solution for each problems and skip other solution for that problem. In educational rounds all your solution will be judged and 1st one will be counted which passes the system test.

    6. In normal round final standing is given based on points earn from all solved problem. In educational round standing is given based on no of solved problem. If no of solved problem is equal then time penalty is used to break a tie.

    NB: Div3 rounds follow the rules of educational rounds.

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

      Thank you, sounds like these rounds are not too harsh and beginner friendly.

      One other thing, How do you hack during a contest or after its over? After some research I found out it gives you points after successful hacks. What I don't found out how you do it?

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

        In normal codeforces round you have to lock you problem first. When you lock your problem you can't resubmit that problem during contest time. After you lock your problem go to room tab and here you can see solutions of other participants who are in that room. You can hack or see solutions for those problem which you have locked.

        Successful hacking gives +100 and unsuccessful attempts give -50.

        In educational and div3 rounds you can see any solution you want. Then you can hack one from status page if you think that solution is not fine enough. This hack has no points.

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

      Are there points for hacks in educational rounds?

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

      In normal round you got -50 penalty if you passed the problem from pretests

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

      As far as I remember educational rounds also have system tests after them, after hacking phase. So #4 is only about name of verdict, isn't it?

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

      Why does the educational round give accepted instead of pretest passed?

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

      Normal codeforces round has 50 penalty for wrong submission afaik.

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

      I have a doubt. If the round is rated for only people less than 2100 rating, why is the rank calculated considering all ratings. And also, is there the case with rating change as well ??

      Just a doubt ...

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

        Contestants with rating >=2100 are one final standing but rating doesn't change for them. Rating only change for them who have rating less than 2100.

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

          yes, but if they are in the ranklist that means the ones who are below them will suffer rating loss and high ranks..is it the way educational round rating system works ?

          Its a doubt !!

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

            They will be not considered while calculating rating. Only rank of official participants will be considered.

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

      thank..so many doubt are now clear..one last question ...is there time for hacking phase after the normal contest like div 1,2??

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

        No. there is no hacking phase in div1,2 rounds. But you can hack during contest.

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

    You can read about educational rounds here

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

Good Luck everyone

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

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

every time

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

Pretests have been extremely shit recently. Like seriously does it hurt to make good pretests and spare us from misery?

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

Why the educational round harder than normal div 2 round is it a lie or not

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

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

Educational rounds never let me down.I hope you enjoy all of this!Good luck and high rating!

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

Educational rounds have never let me down.I hope everyone can enjoy this.Good luck and high rating!See you in the top list!

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

    You had to edit your comment thrice to say this?

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

      thrice !! English Language experts prefer to say 'once' and 'twice' instead of 'one time' and 'two times;' but the –ice suffix ends there, –'three times' is standard expression in today's world and not 'thrice. ... To answer the question (title) of this post, 'Yes, 'thrice' is a correct English word; and yes, it is dated! i copy this from google :)

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

        not sure what you mean by "english language experts", but I definitely remember hearing thrice being used so it can't be that archaic

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

[removed]

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

What people think simultaneously means??

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

I'm sorry but this round is one of some rounds that mostly made me be confused by its statements :|

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

simultaneously really ? :( @awoo MikeMirzayanov

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

    Till the last 10 minutes, I thought both of them have to end up at 0 together in a single step and then I see in the contest announcement that x=1 and y=0 become x=0 and y=0." simultaneously" didn't let me solve any further questions.

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

    I feel for you, this took my 40 mins ... RIP Rating

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

    This round should be unrated IMO because of the ambiguity of questions

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

    And 01 has period of 2 :| Omg :(

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

that C killed me

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

Sorry to say,But Problem statement was not fully clear for problem A.Which cause penalty for many contestants.And too many Announcement during the first 1 hour.Hope,next time statement will be clear enough.

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

I'm really confused that when I choose not to see unoffical participants I see load of yellow and red names in the first 100.How are the D2 participants' rank calculated?Does Codeforces calculate our ranks removing them?

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

    Yes, they appear on the official scoreboard but don't count when calculating the rating distribution.

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

Sorry to say,but problem statement of A was not clear enough,which caused unnecessary penalty for many contestants.Also there were too many Announcement during the first hour.Hope,next time problem statement will be clear enough! :(

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

contest is still running(only 6 mins remaining) and i haven't been able to solve a goddamn single problem. wanna die.

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

[removed]

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

Your goal is to make both given integers equal zero simultaneously : this statement cost me 5 WA + 63 min to submit

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

What is test 3 of C?

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

Am I the only one who dislikes problems like D where you need to print one of the solutions rather than just saying what the minimum value of best solution would be? Seems annoying to code.

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

Problem C — test case 3. Can I have some example?

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

In problem A, the word 'simultaneously' has been used in a very wrong way. Because of this, I thought if we have states (0,1) first we have to go to (1,1) and then to (0,0). It cost me 3 penalties and complete waste of 1 hr.

How about using 'both' instead of 'simultaneously'?

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

    We used this word to cover the fact that you cannot make, for example, $$$x = 0$$$, then make $$$x \ne 0$$$, and then make $$$y = 0$$$ without making $$$x = 0$$$. And the notes for the first example showed that $$$(0, 1)$$$ to $$$(0, 0)$$$ is possible.

    I don't think that there is a perfect wording for such problems (''both'' implies some questions like ''can we make $$$x = 0$$$, then make it non-zero, and then make $$$y = 0$$$''). Perhaps a lot of inline-examples would help, but make the statement much more cumbersome.

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

      Contest should be unrated as problem statement was really confusing

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

        I too got 2 wrong submissions and it caused confusion to a lot of people, but simply because of that you cannot make whole round unrated!

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

        I don't think so , i was able to understand problem statement very easily ,Although ,i am not a native english speaker.

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

          I politely disagree with you. If you will see some other questions here, simultaneously implies that both reach together. The distinction is that of "simultaneously reaching zero" and "simultaneously being zero" I think, and in this question they meant "simultaneously being zero".

          Though in contest one can always ask question and clarify, I did that. But rating suffers if one is not able to solve other questions.

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

      Your example added more confusion.

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

        exactly! instead of saying that the word simultaneously is not to be considered!The explanation was more confusing!

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

      How though would it make a difference if you didnt cover up that fact?

      The word "simultaneously" used in this context literally (in all sense) means that going from state 0,1/1,0 to state 0,0 is not correct

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

        Why does it mean so? If we go from $$$(0, 1)$$$ to $$$(0, 0)$$$ then both numbers are $$$0$$$ simultaneosly.

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

          Because "simultaneously" means "at the same time" or "at the same instant" (try googling it)

          and making x and y to 0 simultaneously means making them 0 at the same time/instant

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

          This is from the problem statement "Your goal is to make both given integers equal zero simultaneously". Here, you didn't make both given integers equal zero simultaneously because one has been already zero the other non-zero.

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

            The last operation makes them both $$$0$$$ at the same time, so the condition is met.

            Okay, there might be more than one way to understand it, but the example notes and the clarification system are working for exactly this reason — if you think that you don't understand something, ask a clarification.

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

              Well, I thought I understood the problem as the way I explained, and sadly that interpretation of the problem statement works on the sample cases.

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

                But it does not work on notes (which are part of the statement).

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

                  I don't think an explanation to a test case justifies an incorrect statement. Everybody is more likely to read the statement and the testcases rather than the explanation to the testcases, especially for problem A

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

              It wasn't one of they way one could understand it. It was the right way to understand. Yes, one could have got the intended meaning by looking at the notes, so to demand that contest be unrated is not sensible at all.

              But please refrain from using words you don't know the exact meaning of.

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

            No, problem statement is correct. They are zero at the same time instant (simultaneously) at the end of the operations. That's it. The fact that one of them was zero beforehand does not matter.

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

              in a way that is simultaneous (= happening or being done at exactly the same time):

              this is from the dictionary, which clearly states being done at the same time. x and y would be 0 after the operation does not mean x and y became 0 simultaneously.

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

                I am not disagreeing that it could have been worded better to avoid any confusion at all. But the author's usage of simultaneously is not wrong.

                Regardless, the round should remain rated.

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

                  The author's usage of simultaneously is incorrect

                  The statement specifically mentions

                  "Your goal is to make both given integers equal zero simultaneously"

                  If it did not have the word "make" I would have accepted the problemsetter's interpretation of things, but adding the word "make" in the same sentence suggests that both x and y have to BE MADE equal to 0 at the same time and not that they have to both BE 0 at some time.

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

                  Regardless, the round should remain rated

                  I never said anything about the round being rated or unrated. Just wanted the authors to know that statement was misleading for some people which could have been avoided.

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

                You're trying to make them both be 0 simultaneously, not change them to 0 simultaneously, and the problem statement obviously said the former way.

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

                  Exactly, making them zero at exactly the same time , that's what simulataneously means. And honestly if you are differentiating between make and change then by doing so even you are agreeing that it was ambigous.

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

                  the statement said "make both", not "make both be"

                  make both suggests changing them to 0 simultaneously

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

                  If you change one to 0 after the other, you're still making both given integers equal zero at the same time, not implying you have to change them at the same time. I don't get the confusion.

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

                  The debates reached maximal permitted depth Let us stop, we both are viewing it from different angles and thus it seems different to both of us.

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

          yes both numbers are zero simultaneously, but the statement says "your goal is to make both numbers equal to zero simultaneously". This is a dangling modifier as it is unclear whether "simultaneously" refers to the numbers being equal to zero, or to making the numbers equal to zero.

          I think removing the "simultaneously" actually makes the statement clearer. If you want to emphasize that both numbers need to be zero at the end, I would prefer phrasing it as "your goal is to make both numbers zero after all the operations"

          (just sharing what I think people are complaining about, I understood the statement in one try because of the example)

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

      You could perhaps say, at the end of all operations, $$$x$$$ and $$$y$$$ must both be $$$0$$$. The current statement wasn't optimal (the announcement could have been part of the problem statement), but I agree that the question itself wasn't ambiguous.

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

test 2 for problem A is just making me nuts..

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

    I guess you missed "long long". The answer is overflowing integer limits.

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

I reduced the problem E to the following:

Distribute n distinct objects into n-k distinct bags such that each bag gets at least one object. This is solvable through Inclusion-Exclusion but how to do it efficiently? Is there any other way to solve the problem?

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

    yes, i also reduced to exact same, but cant move ahead after that.

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

    .

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

    Another solution described here

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

    The number of ways to put $$$n$$$ objects into $$$n-k$$$ bags is $$$(n-k)^n$$$. This also counts all the configurations with one empty bag, so we should subtract $$$(n-k-1)^n\cdot\binom{n-k}{1}$$$ (number of ways to choose the 1 empty bag, and put $$$n$$$ objects into $$$n-k-1$$$ bags). Now, this subtracts off too many configurations with two empty bags, so we should add $$$(n-k-2)^n\cdot\binom{n-k}{2}$$$. Continuing this gives the answer as

    $$$\sum_{j=0}^{n-k} (-1)^{j} \cdot (n-k-j)^n \cdot \binom{n-k}{j} .$$$
    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      Thanks emma, I just saw your submission. Damn it! It didn't occur to me to use binary exponentiation to solve it. I just gave up after reaching the expression :(

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

    After you've decided a distribution with positive integers $$$a_1,...,a_{n-k}$$$ and $$$\sum a_i = n$$$, you can arrange them in $$$\frac{n!}{\prod a_i!}$$$ ways. So the answer is coefficient of $$$x^n$$$ in $$$\left(x+\frac{x^2}{2!}+\frac{x^3}{3!}+\cdots\right)^{n-k}=\left(e^x - 1\right)^{n-k}$$$. Now you can expand it with binomial theorem and extract answer in $$$\mathcal O(n)$$$.

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

    Can you tell how you reduced the problem to this?

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

      To attack every empty cells, either every row or every column contains a rook (both only if $$$k = 0$$$). Now notice that , if, say, you have decided to fill every column, you will have to group pairs of attacking rooks within the different rows. A row will consist of possibly $$$0$$$, or more rooks. $$$n$$$ rooks means $$$n-1$$$ pairs, for $$$n \geq 1$$$. Now we are almost there for the reduction. There will always be $$$n-k$$$ groups of row (or "used" row if you prefer). If less, it can be shown that there are too much pairs. If more, there are not enough. The $$$n-k$$$ rows are the "bags". The position of the rooks in the columns is important. That is why you have the forumla $$$(n-k)^n$$$ at the beggining.

      $$$ $$$

      At the end you also need to multiply by two if $$$k=0$$$ (because of what I said at the beggining) and... you have to take into account that you also have to ditribute the "bags" ($$$n-k$$$ of them) to the different rows ($$$n$$$ of them). This is yet another binomial coefficient.

      $$$ $$$

      I hope this was somewhat helpful, the editorial should be better at explaining the solution anyway :)

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

        Thanks a lot for the great explanation

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

        I would like to add an explanation for "why exactly n-k groups of row?" Let q denote the number of chosen rows. Assume our chosen rows are r(1), r(2) ... r(q). Let Cr(i) denote the number of rooks in each row. As the number of attacking rooks for each row is Cr(i)-1 , so we have this equation: Cr(1)-1+Cr(2)-1+ .. +Cr(q)-1 = k
        From this we can get Cr(1)+Cr(2)+...+Cr(q) = k+q
        So q = Cr(1)+Cr(2)+...+Cr(q)-k = n-k

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

for future reference

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

Video tutorials here for some of the tasks, you can also join my discord server for more insights

C

D

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

Wierd Runtime, please help! I am getting Runtime Error on submitting div2D on Codeforces on 1st sample, but same code & input runs & produces perfectly correct output on online IDE at Codechef.com/ide !

https://codeforces.com/contest/1342/submission/78209696

How is that possible? I have correct code but can't get accepted because of this. MikeMirzayanov awoo

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

    When weird stuff like this happens, this usually means that your code has undefined behavior (like indexing an array with an invalid index or using the value of an uninitialized variable).

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

      I cross verified, there seems no variable uninitilaized. set I am using, made sure to only erase if a value exists. That makes me believe, there is no undefined behaviour. Please point out if I am missing something. Thanks Be_dos

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

    same thing happens to me also.

    https://codeforces.com/contest/1342/submission/78207115

    My code also gives a runtime error. I tried on CodeChef ide also, it works perfectly. But I can't find the reason.

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

"Your goal is to make both given integers equal zero simultaneously"

Why on earth did you have to use the word "simultaneously"? I thought it means we have to use operation 2 to go from 1 1 to 0 0 (to make it simultaneous) I wasted more than 20 mins on this until i read the description of the test case and asked the question to the setters

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

    lmao same, just added to consider the case 'a' on both x and y and it got accepted

    EDIT: sad thing is, i just noticed that problem statement says 'move from 0:1 to 0:0 is valid'

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

I had to deal with 6 penalties before the statement of A was made clear. This is really irresponsible. Although my rating increases, I demanded the round should be unrated due to some avoidable mistakes.

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

I missed placing exactly n rooks part in E and tried solving this problem for almost entire duration of the contest: placing some x rooks on the board such that either all rows are occupied or all columns are occupied (or both). :/

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

how to solve F?

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

The word simultaneously in the text of Problem A was seriously misleading. It made it seem like the last operation must have been of type 2 so that both values would arrive at 0 simultaneously.

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

    wait that wasn't what they meant?

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

      Apparently the values could arrive to 0 at different steps, as well. They made an announcement stating that during the contest.

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

I misunderstood the term "simultaneously" and wasted 15 mins.

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

Problem A made me zoned out for 25 mins.

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

Upsolving C and D live on YouTube: https://youtu.be/XeK6lYKd8W4

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

So my code for problem 'C' decided to run correctly 10 seconds after the contest cool cool cool cool cool cool cool cool cool cool cool cool cool cool

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

    Try this .
    1
    3 4 1
    12 12
    Ans should be zero but your code gives 1 .

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

      include

      include

      include

      include

      include

      include

      include

      include

      include

      include

      include

      include

      include

      include

      define endl "\n"

      define pb push_back

      define ll long long int

      using namespace std; int main() { int t; cin>>t; while(t--) { ll a,b,q; cin>>a>>b>>q; if(a==b) { for(int i=0;i<q;i++) { ll l,r; cin>>l>>r; cout<<"0"<<" "; } cout<<endl; } else if(a<b) { ll k=0;

      for(int i=0;i<q;i++)
          {
              ll l,r;
              cin>>l>>r;
              ll cnt=0;
      
             cnt=r-max(l,b)+1;
            if(b%a!=0)
             cnt-=b*((r/a)/b-(max(l-1,b-1)/a)/b);
             else 
             {
                 ll g=__gcd(a, b);
                  cnt-=b*((r/g)-(max(l-1,b-1)/g));
             }
      
              cout<<max(cnt,k)<<" ";
          }
          cout<<endl;
      }
      else 
      {
           ll k=0;
           for(int i=0;i<q;i++)
          {
              ll l,r;
              cin>>l>>r;
              ll cnt=0;
      
             cnt=r-max(l,a)+1;
             if(a%b!=0)
             cnt-=a*((r/a)/b-(max(l-1,b-1)/a)/b);
             else 
             {
                   ll g=__gcd(a, b);
                   cnt-=a*((r/g)-(max(l-1,b-1)/g));
             }
              cout<<max(cnt,k)<<" ";
          }
          cout<<endl;
      }

      } return 0; }

      how about now??

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

        At least put your code in spoiler ....
        1
        9 12 1
        1 192
        Ans is 121 and your code gives 169 .

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

In problem A, the word 'simultaneously' confused me. Because of that, I thought if we have states (1,0) first we have to go to (1,1) and then to (0,0). It cost me 3 penalties and waste of 25 minutes.

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

    just simple English, simultaneously means at same time. so A and B have to be zero at same time. you're not even supposed to have 1 0 in first place

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

Hi, I tried a greedy solution for D. I sorted an array and added tests from the smallest, for each of them checking how many more I could add to one testcase. It got WA on test 11.

What do you think is the counterexample?

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

    Try this:

    5 3
    1 2 3 2 1
    2 1 1
    

    You can construct an answer with 3 multitests instead of 4 as given by your code.

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

Hey MikeMirzayanov, I got unnecessary 2 WA in problem A because I considered the condition to make both x and y simultaneously zero. Though I can't ask back the overall time lost due to this but if possible can those two penalties be removed! Thanks in Advance.

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

    in correction too! it was not mentioned correctly that simutaneously is not to be considered! worst educational round!!

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

A and B again supersimple problems hidden in complecated text.

In A I needed half an hour to get it that we cannot use opposite signs in operation b. Of course the statements states so, but that was mostly invisible to me.

And D, sorry, simply to much words, I am not able to understand the sentences.

Usually posting like this get downvotes. I know. Thanks.

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

What's wrong with my solution of F?

What's the meaning of "wrong answer 'to' position should be in [1, 14] (test case 4)"?

my submission

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

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

Can someone tell me where my greedy approach for D fails. Here is what I did I sort the tests with respect to their sizes. I pick the array with largest size and put it in first testcase. Now I pick the next largest array , say of size X and the testcase with minimum tests till now and check if No. of tests in this testcase + 1 <= c[X]. If the condition holds, I put this test in the chosen testcase, otherwise make a new testcase. I got a wrong answer on TC 11

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

    try this test case :

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

      I couldn't understand how the greedy solution with your test case would give a different answer. Can you provide any other test case?

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

      Kill me !! Kill me. My Greedy approach is correct . There was a single line I missed in the implementation. I used a min heap and I forgot to insert the previous topmost element(which I had popped) whenever I am creating a new testcase. It got accepted now and I am confused why could not I find this in more than an hour.

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

In Problem C,

O(test * 3 * gcd(a, b)) times remainder calculation cost TLE on test 4. Does the remainder calculation cost this much?

:(

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

    Your time complexity for solution 78195345 is O(test * q * a * b). For every test, for every query you iterate x at most len times (which can equal to a * b) so you have around 100 * 500 * 200 * 200 = 2e9 operations times constant. You also have remainder calculation so I guess it is a rather predictable verdict.

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

How is 78182933 doesn't get TLE?

It has linear complexity for every query or did I miss something?

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

    As far i understand he calculates curr in the loop which is never used after that. As it is never used so compiler removes that loop as a part of optimization. As a result the loop doesn't get a chance to run so there is no tle.

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

      Thanks, you were right. I don't know that compiler can skip unnecessary operation.

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

Question C: Which number $$$x$$$ in the range $$$[100,200]$$$ other than $$$141-149$$$ gives $$$(x \mod 7)\mod 10 = (x \mod 10)\mod 7?$$$ The answer is $$$91$$$, so there should be $$$10$$$ such numbers.

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

Fail on 1605th number.

Oh cmon? How can I debug? 78209018

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

Got no idea what's wrong with my C submission.

Could anyone take a look at it? https://codeforces.com/contest/1342/submission/78197703

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

is it possible to solve C without prefix sum / dp ?

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

    There's a dp/prefix sum solution for C?

    I just excluded the numbers from i*LCM(a,b) to i*LCM(a,b)+max(a,b) for i=0,1,2,3.. from the range l to r

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

    Yes it can be solved. You can check my submission https://codeforces.com/contest/1342/submission/78176991

    You can use the fact that x%a%b == x%b%a occurs at every multiple of lcm(a, b) for exactly max (a, b) times. You just get that and you have your answer in O(1) for each query, or log(n) if you consider GCD.

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

      I've tried things similar to this but it's not working for me https://codeforces.com/contest/1342/submission/78229431

      can you tell any counter case on which this will be failing ?

      UPD: Just figured I was unnecessarily assuming that if a and b are divisible then the o/p will always be 0. thanks for the help tho

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

        i also assumed the same and was getting WA on test 2 can you pls explain why that assumption is wrong my submission on c

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

          I also put the same condition though, and mine is accepted, so it must be something else, I will try looking into test cases after system testing.

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

        The problem was not the a and b divisible condition, but you did not take inputs when they were divisible. You just printed 0 q times. you should also take left and right inputs.

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

that fucking simultaneously word in problem A .......

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

    I don't even understand what are you talking about.

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

      they have mentioned that we have to convert x and y into zero simultaneously and later they made an announcement that it is not req.

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

        I agree that it might be misleading but I didn't have any problem with understanding that word. I take it as the meaning of a simultaneous equation and didn't notice that word until I see this comment.

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

          Pls don't take it as the meaning of a simultaneous equation...

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

          Please never take it as the meaning of a simultaneous equation dude

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

simultaneously means at the same time, doesn't it?

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

(https://codeforces.com/contest/1342/submission/78163668)

(https://codeforces.com/contest/1342/submission/78134634)

Exactly same solutions[user:MikeMirzayanov][user:pikmike] Disqualify both of them from contest

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

Hm, my idea for E was wrong, but I don't know how:

Something like, when $$$0 < k < n$$$, we know either all rooks will be on distinct cols or all rooks will be on distinct rows, (and not both since $$$k \neq 0$$$), since two rooks sharing a col and two rooks sharing a row would leave some row and some column untouched (and thus the square at their intersection untouched). Then, we can WLOG assume all rooks are on distinct rows.

Consider all the columns that contain a rook. If we consider all the rooks on that column a path graph, we see that it contributes exactly the number of edges it has to the number of pairs that attack each other. However, we also know that there will be $$$k$$$ edges in total, and since the whole graph is a forest, there should be $$$n-k$$$ components, i.e. $$$n-k$$$ columns containing rooks. So, the question then becomes how to partition $$$n$$$ objects into $$$n-k$$$ nonempty components (stirling # of second kind), and then multiply that by the $$$n-k$$$ columns that the rooks can occupy, and then multiply that by 2 to account for distinct columns cases.

Anyone know where the error in this logic is? I plugged the formula into wolfram (mod[2*stirlings2[1337, 1295]*(1337 choose 1295), 998244353]) for test 4 and it was incorrect.

EDIT: As BledDest pointed out, one just needs to multiply this final formula by $$$(n-k)!$$$ to index the columns for specific subsets, then it should be fine.

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

    When you multiply the stirling # of second kind with a coefficient to choose $$$n - k$$$ columns, you should consider the fact that the subsets in definition of stirling numbers are not indexed.

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

    shouldn't answer be simply stirling(n,n-k)*chose(n,n-k)*2 ?

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

      Stirling number would count all required possible arrangements. Let one such possible arrangement be set1. Set1 would contain n-k elements, each element would correspond to a valid arrangement for a column.

      Then you have to select n-k columns from the board to place those valid arrangements (combinations), let the set of selected columns be set2.

      Then each different function from set1 to set2 would correspond to a different way you can arrange the rooks. (The function needs to be one-one and onto i.e invertible). Number of different functions from set1 to set2 is (|set1|)! or (n-k)!.

      You can also think of it as you have n-k diffrent objects and you need to put them in n-k different slots, how many ways are there to do it (permutations).

      Hope it helps!

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

    a counter test case in case it helps : 1 248 12 2 491 1289 839 1234

    o/p for this should be 551 243 .

    Hope this helps !

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

Thanks.

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

    The only contest u joined is an April Fools’ Contest. Why would u even expect it to be a rated round.

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

    The first contest you took part in was April's Fools so it was unrated There is a 12 hour hacking phase after the contest so wait and you will get your rating tommorow.

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

My rating and confidence level is going down simultaneously....Thanks for problem A.

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

Time Limit of problem C was misguiding.

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

For problem B, I approached the question the same way as others. Printing "01" up to s.length() times. But in the clarification panel, the value of k for string "0011" is 4 but it is 2 if we print "01" up to n times(n == s.length()). Can anyone explain what am I missing here?

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

    I think you are right. The statement of B make me confused!

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

    it just states the definition of a period. Explanation in clarification panel is not much related to original problem.

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

task A

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

Wait darn solved ABD and didn't get C...played around with gcds/mods and found some progress but whatever. Why doesn't O(ab(t+q)) pass? It's the naive solution but it seems to be well within the time limit of 3.5 seconds (2.4*10^7 operations -- i've had solutions with more operations and less time pass)

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

    You can do it in O(t*(ab+q)) if you precalcutate a prefix array. Such solution of mine took 498ms.

    This is one thing and the second is maybe Java is slower than C++.

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

      Ah ok, I should have done prefix array, maybe the complexity would have been reduced by a constant factor and pass but yeah C++ is definitely faster than java too :(

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

    can you please tell me how many max operation can be done in 1 sec

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

      Not entirely sure but somewhere between 10^7 and 10^8 (since for some problems O(N^3) for N=500 passes and some other variants which have >=10^8 operations)

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

    and also how mush time should i spend on C and then jump to D.

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

    Yeah, I also didn't get why the TL. No idea why my solution failed. But in the end I managed to do O(1) per query. The main thing to notice was that every number from b to lcm-1 is good. So you don't even need to precalc anything first and can answer each query in constant time.

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

      can you please explain

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

        First you need to check how many numbers are there between 1 and lcm-1 that satisfies the property. Let's say a is smaller. Then any number X greater than or equal to b will satisfy. We can prove this as follows.

        Let's say X = bq+r, Then (X%b)%a = r%a. Now we need to write (X%a)%b in similar form. Here notice that bq is less than X, and since X is less than the LCM, bq is also less than LCM. Therefore it can't have a as a factor.

        So bq = aq'+r'. Therefore X = aq'+r'+r. Taking modules, we will get (r+r')%a.

        Since r' is neither 0 nor a, therefore it is different than r%a. Thus any number greater than equal to b satisfies.(Upto LCM that is)

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

          how are you comparing (r+r')%b and r%a???

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

            (X%a)%b is reduced to ((r+r')%a)%b. If you notice, the second modulo by b is unnecessary as (r+r')%a is always less than b. So it reduces down to comparing r%a and (r+r')%a

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

    You can answer each query in O(1).

    I just excluded the numbers from i*LCM(a,b) to i*LCM(a,b)+max(a,b) for i=0,1,2,3.. from the range l to r. Mycode

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

      Came up with the same logic during the round, but sadly my implementation was a complete garbage. :/

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

It is too hard to read the Problem D statement.

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

"Your goal is to make both given integers equal zero simultaneously"

If it did not have the word "make" I would have accepted the problemsetter's interpretation of things, but adding the word "make" in the same sentence suggests that both x and y have to BE MADE equal to 0 at the same time and not that they have to both BE 0 at some time.

This cost me 3WAs and almost 20 minutes

I'm disappointed

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

    i ll change my username to "Simultaneously" next year as a reminder for today's problem A!

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

Why does life as well as codeforces keep on fucking with me simultaneously! Eh? Thanks to Problem A.

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

I was able to think about using LCM in the Problem C But Quite didn't move forward from it Can anyone his/her approach It will be a nice help .

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

i tried solving question C using digit dp as I was recently studying this, while solving I realised it would tle as my dp was having high dimensions for modulus of a and b, can anyone tell me how to do it using digit dp if possible

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

    I dont think so TLE. Because a,b<=200. Should have passed with 3.5 seconds. :)

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

      their lcm can be as high as 40000 , so it might give tle if I set mod variable this high my dp looks like dp[position][tight][start][mod], here mod can be upto 40000, position upto 20, tight is bool, start is bool, plus 500 queries and 100 test cases

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

Please uphack my solution to F. I am not using any kind of bitmask dp.

UPD:Got hacked by one of the authors. That's kinda cool. Thanks Neon.

UPD2:Somehow I made it work in 1.5s just by reserving memory for vectors.

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

Am i the only one who felt much more easier with D than C? For me, D's approach was quite simple, which i can't say for C (and also TL for C kinda confused me).

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

Is C solvable with digit dp? If yes, it would be awesome if someone explain the solution with digit dp.

Thanks in advance. :)

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

Problem C can be solved in $$$\mathcal O(1)$$$ per query (assuming it takes constant time to compute GCD) without any preprocessing. Assume $$$a < b$$$ and take some $$$x = qb+r$$$ with $$$0\leq r < b$$$. Then $$$(x\bmod a)\bmod b = (x\bmod b)\bmod a$$$ translates to $$$x\bmod a = (x\bmod b)\bmod a$$$ and thus $$$qb+r \equiv r \pmod a$$$ implying $$$a$$$ divides $$$qb$$$. This gives us $$$\frac{a}{\gcd(a,b)}$$$ divides $$$q=\left\lfloor\frac{x}{b}\right\rfloor$$$. So given $$$l,r,a,b$$$ we're looking for number of $$$x$$$ such that $$$\frac{a}{\gcd(a,b)}$$$ divides $$$\left\lfloor\frac{x}{b}\right\rfloor$$$ which is easy to count solving an inequality or two.

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

    Yes, that is exactly how I solved the problem. I didn't realise there is an easier solution.

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

According to A, everyone reached the finish line simultaneously.

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

OK well, why the heck do people write this kind of obfuscated code? only to evade hacking? https://codeforces.com/contest/1342/submission/78201792

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

Why would greedy solution not work for problem D?

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

    It works. Maintain a set that stores indexes of test cases ordered by their current size and iterate over the range $$$[1,k]$$$ in descending order (from $$$k$$$ to $$$1$$$).

    In $$$i'th$$$ step, take the index of the test case with the smallest size from the set.

    If it's size is less than $$$C_i$$$ then fill it with the current value $$$i$$$ until its size becomes $$$C_i$$$ or all the array with size $$$i$$$ become used.

    Otherwise, create a new test case and fill it with current value $$$i$$$ until it's size becomes $$$C_i$$$ or all the array with size $$$i$$$ become used.

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

      I find your solution very similar to mine except that i'm getting a WA on test 11. Can you check it why?

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

        Your solution fails on following testcase
        6 2
        1 1 2 1 1 2
        3 1

        Your code prints 3 testcases whereas answer is
        2
        3 2 1 1
        3 2 1 1

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

          Thanks. It seems that I forgot to reinsert the popped element in set.

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

        I was getting WA on test 11 too. Try your code on this input-

        6 10
        5 1 10 8 8 7
        6 6 4 4 2 2 3 2 1 1
        

        The correct output should be-

        2
        3 10 8 7
        3 8 5 1
        
»
4 года назад, # |
  Проголосовать: нравится +32 Проголосовать: не нравится

Why on earth did I solve A for any whole x, y (including negative) ?

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

    I just realized that I solve it for the negative too after seeing your comment. There is a negative number in the example of the question when it introduced the operations (not the test case). That was so misleading.
    https://codeforces.com/contest/1342/problem/A

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

    meetoo

    i am with you init bro.

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

    Because it was problem A and most people just want to solve it ASAP without giving it much time.The people who faced problem due to the word simultaneously would not have faced the problem if they read the samples. But people generally want to solve it as quickly as possible without even reading it completely xD

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

why there are so many successful hacks on C

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

    Maximums of hack submissions of problem C are Time Limit Exceeded(TLE). Because worst cases are not available in the pretest.

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

Am I the only person who didn't even notice the simultaneously word in the contest time but successfully pass the pretests?

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

Statement of problem D is difficult to understand + printing the actual answer was really annoying

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

    I thought so many different useless way to print the answer and in the end I just used V[i%Test].push_back(M[i]) after sorting M. Here Test is the Min number of tests.

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

      Yeah I did exactly the same thing (after the contest though lol) But that was annoying I got the min number of test cases like 30 min before the end of the contest

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

    It's actually not hard to print the actual answer. If you just sort the array sizes and assign it to all tests turn by turn greedily, by exchange argument, it will satisfy the condition

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

Does anyone have any idea on Test #16 in D? I can't see why am I getting TLE in my presumably linear desicion: 78188697

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

Problem C https://codeforces.com/contest/1342/submission/78221117 My code fails on testcase 2..please give some test cases..on which my code fails..

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

https://codeforces.com/contest/1342/submission/78225763 can someone give me a testcase where my code fails?

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

Doh! Just now saw that problem E specified "n rooks". I was trying to solve it for an arbitrary number of rooks, which is much, much harder :-(

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

    How would you solve it if you can have ANY number of rooks? I also didnt read the 'n rooks' condition at start. To make it a bit simpler lets say the constraints arent a problem. How can we calculate the answer in the best possible time complexity?

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

      Ok, here's about how far I got. Let's start by giving a number of rooks X; we'll come back later to which values are valid.

      Let f(r, c) be the number of ways to fill an r×c grid (1 <= r, c <= n) with X rooks such that every column has at least one rook. I think this can be computed with inclusion-exclusion in O(n³). Next let g(r, c) be the number of ways to fill an r×c grid with X rooks such that every row and column has at least one rook. Again, I think inclusion-exclusion can compute this (from f) in O(n³).

      There must be either a rook in every row or in every column (or both) to attack all empty squares. Let's consider the "every row" case, and assume exactly c columns are occupied. Then K=2X-n-c so we can solve for X, and take g(n, c) times a suitable binomial coefficient. Repeat for all values of c, and treat the all-columns case similarly.

      That should give O(n⁴) time overall, assuming I haven't missed anything. I feel like there might be some clever way to reduce it to O(n³) but I'm not seeing it at the moment.

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

    I missed n rooks part too. But I went back to reading the statement when I realized you can't even find out the number of ways of placing k rooks in an n x n board (without any constraints) in time better than $$$O(n^2)$$$.

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

    I missed the statement 'each empty cell is under attack' and spent 30 minutes solving the task without it.

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

I'm trying to solve C by utilizing the fact that x%a = (x%b)%a For example if a is 4 and b is 6, then I'll find the count of numbers having remainder (0 with 4 & 0 with 6), (0 with 4 and 4 with 6), (1 with 4 and 1 with 6), (1 with 4 and 5 with 6)....(you get the idea).

I find the count of numbers having some (p,q) remainders with (a,b) respectively by finding anyone such number, then every other number with same remainders will (I assume this) be situated at a distances of multiples of LCM(a,b).

I could get the sample tests to pass but failed the next test by an error of 1. Is the approach correct?

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

https://codeforces.com/contest/1342/submission/78205413 can someone help me on why this code failed on large values (problem B)...I know i should have printed characters one by one rather than storing in string variable..but why can not a string variable contain 200 characters ??

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

    it have to resize that t1 thats why it is giving tle

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

      Thank you!!..I made a char array now instead of string with size more than maximum number of characters it should hold and it got accepted now.

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

    Either resize t1 to necessary value or use push_back operation. Your t1 has size 0.

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

How to solve problem F?

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

    Suppose we don't have any constraints on the order of elements, the resulting array just should not contain any duplicates. Let's build the result one element after another in ascending order, so each element we create is strictly greater than the previous. To create an element, just use some subset of elements and merge them into new element. This process can be efficiently modeled with the following dynamic programming: $$$dp_{cnt, mask}$$$ is the minimum value of the last element, if we merged all the elements from $$$mask$$$ into $$$cnt$$$ ascending numbers. To model transitions, we simply iterate on the mask of elements that will be merged into a new one, and check if its sum is greater than the last element we created. This runs in $$$O(n3^n)$$$.

    Okay, how about maintaining the order? When we create an element by merging some elements of the original array, let's choose some position of an element we use in merging and state that all other elements are added to it. Then, to ensure that the result is ascending, the position of this element should be greater than the position of the element we chose while building the previous number. We can add the position we have chosen for the last element to the states of our dynamic programming, so it becomes $$$dp_{cnt, mask, pos}$$$ — the minimum value of the last element, if we merged the $$$mask$$$ of elements into $$$cnt$$$ numbers, and the last element originally had index $$$pos$$$ in the array.

    Using some greedy optimizations (for example, we should not iterate on the position we are choosing to merge — it can be chosen greedily as the leftmost position after the position of previous element we are taking into consideration), we can make it $$$O(n^2 3^n)$$$, yet with a small constant factor.

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

      I got $$$O(n 3^n)$$$ 78249435 because I conjectured that the minimum value of the last element can be implicit in $$$dp_{pos,mask} = $$$ (the minimum number of operations, the minimum value of the last element), What do you think ?

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

how many iterations is one second in codeforces?

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

how many iterations is one second in codeforces?

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

    1,2 or 3s are just to manage the constant factor. In general, if N is 10^6, then O(NlogN) solution will pass, given some caveat. There's a big hurdle of printing, which is the slowest part of the code. So if there's a lot of things to print like, maybe a matrix per test case, or answer to a lot of queries, then that can also affect the time.

    In case of C, I think most of the TLs are because of that.

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

      I agree with you but I would like to know how many iterations are approximately one second in codeforces because what runs on my PC in 5 or more seconds in codeforces gives me in 1 second what left me surprised. I always did the calculation with 1 second as 1e8 iterations and I think this is not the case.

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

I have logic for C plz tell me what is wrong with it

let a<b. Now we can calculate for no. [1-b] which satisfies that equation, now as the modulo function is periodic so the answers will also be periodic and we can easily calculate them.

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

I couldn't manage to solve C during the contest even though the recurring pattern was visible.

Here is my submission.

https://codeforces.com/contest/1342/submission/78232191

My logic was based around multiples of lcm+max(a,b). If someone can find something wrong in the solution please hack it. Thanks in advance!

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

I have logic for C plz indicate what is wrong with it. let a<b. now we can calculate the answer for range [1,b], now as the modulo function is periodic now we can easily manipulate this to get and for the given range.

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

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

I submit to problem C a solution in O (T*(Q + log( max(a , b) ) ) ) and it accepted. You can see it here: https://codeforces.com/contest/1342/submission/78217111 . I would like to be told if it is correct or not.

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

    78195754 Can someone help me know why this soln exceeds the Time limit. Thanks.

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

      Your LCM can be around 40000, so in worst case, you'll have this much iteration per query.

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

      your complexity is $$$O(tq\operatorname{lcm}(a,b))$$$ which can be $$$O(100\times 500\times 40000)=O(2\times 10^9)$$$, which could easily exceed time limit.

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

I did many unsuccessful hacking attempt will it result in any negative points? Please guide me!

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

I was trying to solve Prob.D using priority queues , but I'm getting TLE

https://codeforces.com/contest/1342/submission/78239810

I tried keeping time O(N) but maybe because I'm copying entire pq.top() in temp each time I'm getting TLE. But how do I avoid this ?

I simply tried using (pq.top()).push_back(A[i]) but it throws some error saying "passing ‘const value_type’".

can someone help me resolve this ?

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

    You can check out my solution: Soln

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

    The priority_queue does not allow you to change the values inside (because it might change the order), so it only returns a const reference with .top() and you have to pop and then push the elements again.

    To fix it, you could e.g. use vll* or shared_ptr<vll> inside your queue, which is cheap to copy.

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

I have seen many solutions for problem D failing on 11th testcase .What was that can anyone tell me??

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

How does https://codeforces.com/contest/1342/submission/78244632 pass but https://codeforces.com/contest/1342/submission/78244302 fails? There is only one line change, and that line never gets executed. The 'cout << "???"' line never gets executed, since the test passes.

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

Can someone explain why greedy works for problem D? I have a hard time wrapping my head around it.

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

Is it still going to be rated?

A lot of users were affected by the incorrect English in problem A

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

    тогда rated для РУССКИХ!

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

    Yeah i think they should not have mentioned the word "simultaneously". I too was confused. But seeing the number of submissions in first few minutes i think it was clear that there was no need of overthinking.

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

      "But seeing the number of submissions in first few minutes i think it was clear that there was no need of overthinking."

      I disagree with this. Quite frankly, I would have to overthink to interpret it the way the problemsetter did. I'll continue to stand by my claims of the author's interpretation being incorrect given that none of my points have been addressed.

      Maybe this was a result of a lack of testers(nobody's been mentioned on this post)?

      awoo, for future edu rounds, could you at least get more testers(or even people to read over the problem statements)?

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

    IMO, if we make this round unrated, it'll be unfair for people performed well.

    Problem A itself is mainly correct, with a minor(maybe?) mistake

    The word "simultaneously" is not specially marked with bold,that means we don't have to pay much attention to it,although it's a bit misleading.

    However, since the sample explanation is added soon after the contest started, it would be clear what "simultaneously" really means.

    Hope there'll be less confusing statement like this in the future

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

Can someone explain the first test case of Div2E?

What are the 6 arrangements? Isn't this a valid arrangement?

x..
.x.
.x.

x are the rooks, . is an empty cell.

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

I'm new to educational rounds! My solution to B problem was accepted during the contest but now its gone red and i wasn't rewarded for that Question and now its again green. Can anyone explain why so

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

    your solution was incorrect, someone found test where it fails :(

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

    If you made a failed submission for a problem,then the problem will become red during systest.

    But don't worry, once your solution passed the systest, it will become green again.

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

Is Problem F the real-life application of Problem D?

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

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

78261468 can someone please provide a test case where this code fails

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

when will ratings update??....i am eager to see my new rating

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

The educationals have never been friendly to me :-(

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

can anyone please help me what's wrong in my code for C,I checked for numbers of type k*lcm(a,b)+max(a,b) which are in range. https://codeforces.com/contest/1342/submission/78265046

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

Can anyone understands me the div2D. Mainly i don't understand the test 2 first line output . Why that is 2.plz anyone explain. Sorry for poor english.

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

    2 means minimum number of test cases you must have,to satisfy the given condition. And next there will be two line describing those test cases.

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

    In case you don't understand the question: You can assume the problems like this,

    • Given N items with weight [1,K]

    • Given C1,C2,..,Ck which means the item with weight >= K in 1 packet must be at most Ck

    • The task is to separate the items so that the rules no.2 in fulfilled with the number of packets as minimum as possible

    Test case 2:

    6 10

    5 8 1 10 8 7

    6 6 4 4 3 2 2 2 1 1

    N=6 K=10

    Items = {1,5,8,8,7,10}

    C = {6,6,4,4,3,2,2,2,1,1}

    Answer:

    You can separate the items into {10,8,1} and {8,5,7} or {10,7,5,1} and {8,8} or even {10,8,5,1} and {8,7}.

    You can check my solution : https://codeforces.com/contest/1342/submission/78196440 (it's kind a mess tho)

    In overall, my greedy solution goes with:

    -Put the highest weight as the priority

    -While it is available to put them in the packet 1, put 'em. else go to packet 2 and so on.

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

      EDIT:

      For every weight, while it is available to put them in the packet 1, put 'em. else go to packet 2 and so on.

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

System sent me a letter,it said that my code is similar to another person, so I write this comment. I solved 1342D quickly, and then, I had had been thinking about how to solve problem E, but my math ability is not very good, so I can't solve it. train2004 is my friend, all right. After contest, we talked a lot. His opinion is same to me, but I didn't see his code. I haven't thought about the case now. Through this experience, I konw that I should add some personal codes to try to avoid these cases. Thanks for reminding me, I'll notice these by now! Thanks!

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

Nice problems! Everytime I can learn a lot from educational round! Thinks a lot to codeforces!

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

I found out that I would be more likely to drop rating in edu-rounds.

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

Where is the editorial?

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

I have done problem D using greedy approach and I think time complexity is (n+k)log(n+k), but still I am getting TLE on test 16 78266716???

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

I seen all have almost same approach for Problem C. Can anyone tell me how we reached to that approach ? I mean what topic knowledge is required to think for that approach?

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

    just print x% a % b and x % b % a and same or not, for the given example a=4,b=6 and choose like l=1, r=100 you can see the pattern and you can conclude you need the lcm, then it's basic stuff from here.

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

After this contest,system sent me a message:"Your solution 78191609 for the problem 1342D significantly coincides with solutions 78180150".However,I wrote my code by myself,and our code are different.Even if some part looks same,but that is a very common way for solving greedy+priority_queue problems.What can I do? Sorry for poor english.

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

    Ask awoo or MikeMirzayanov for help

    Sorry but I have to say... you're so "lucky"

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

    awoo Could you please check this?Thanks.

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

      No offense but code looks very similar.

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

        Well,if you think this problem like this"greedy is ok.if I can add this m[i] into the smallest set,then do it;otherwise,make a new set",then write code.It's easy to look like others who have the same idea.(And we are classmates,so we have similar code style...)
        But after all,our code really looks very similar.
        So I think I should change my code style to avoid this situation next time. Sorry for my poor english.

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

Why all task were on one topic?

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

I don't know how to solve problem E. Could you help me?

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

Why not to post editorials just after the contest ends (learn from atcoder, codechef ) ,if problems and solutions are already prepared ,then why let others wait for so long ... I am checking after every hour from yesterday for editorials but they are still not posted...

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

    This seems to be limited to Educational rounds and Div. 3s, (most of) the other problem writers seem to have it ready straight away and it's pretty disappointing when it isnt ready hours afterwards.

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

I always find it difficult to solve question like D. I guess D was more of an implementation type question but implementation is not there among the problem tags, can you plz tell me what kind of question should i practice for these kinds of problems.

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

why the editorial is still not uploaded ? (i need hints for problem D)

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

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

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

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

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

Hello, Orange!

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

Can anyone help with TL on problem F?) https://codeforces.com/contest/1342/submission/78328093

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

I've solved it