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

Автор MrPaul_TUser, 3 года назад, По-русски

Привет, Codeforces!

Рад пригласить Вас на увлекательный (а мы постарались его сделать таким) Codeforces Round 734 (Div. 3) — раунд для третьего дивизиона, который состоится в 23.07.2021 17:35 (Московское время). Этот раунд — моя (MrPaul_TUser) первая "проба пера", и, разумеется, я бы не справился, делая его в одиночку — существенный вклад в создание раунда внесли MikeMirzayanov, BledDest и DK318.

Этот раунд содержит 6-7 задач. Задачи подобраны по сложности так, чтобы составить интересное соревнование для участников с рейтингами до 1600. Однако все желающие, чей рейтинг 1600 и выше, могут зарегистрироваться на раунд вне конкурса.

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

Вам будет предложено 6-7 задач и 2 часа на их решение.

Штраф за неверную попытку в этом раунде (и последующих Div. 3 раундах) будет равняться 10 минутам.

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

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

Огромная благодарность WolfBlue, BlueDiamond, harlequen, -is-this-fft-, le.mur, Bench0310, Reiva5, Golovanov399 и Sho за помощь в тестировании раунда и улучшении задач.

Всем удачи и хорошего настроения!

UPD

Разбор задач

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

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

First time being unofficial :)

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

    Reached 1600 yesterday...

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

    Why? This round will be rated for you since your rating is less than 1900.

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

      No, its rated up to 1600, not above.

      "However, all of you who wish to take part and have a rating 1600 or higher, can register for the round unofficially."

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

        So... then what does "only the trusted participants of the third division will be included in the official standings table .... do not have a point of 1900 or higher in the rating." mean?

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

          That means that those people will be included in the official standing table.

          In conclusion that means, not everybody in the official standing table will be rated.

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

    hey! i saw your profile and i'm pretty curious as to how did you become expert in such a small timespan, if possible could you share some tips, tricks or advises? and like what all topics did you practice to reach where you are right now?

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

      I was training kind of hard maybe :) when I was newbie I trained 1600 difficulty problems until I become pupil, after that I started to train 1k8 problems until I reach specialist and expert. Upd: I think the best way to do it is your rating point + 400. (Sorry for my bad english)

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

Now finally my exams are over. I can once again participate in contests.

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

Very glad to see another Div3 in small interval! good luck everyone!

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

Why is it showing registrations completed, does it mean I cant register for the contest now?

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

expert i'm coming

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

I appreciate that the testers are arranged such that their usernames' colors form a palindrome.

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

    "..just like you will be upset if many solutions fail after the contest is over."

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

hope there will be strong pretests as last contest was ruined by weak pretests

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

"I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over."

phew, unlike last contest ;)

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

see my profile I will never give div 3 I dont know how so many people solve so fast and ACM-ICPC rules sucks too.

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

    The way people solve it fast is practice. I did the last div 3 contest just like you and you spent 1:30 hours on D, which isn't particularly hard if you're familiar with this type of idea. Blaming the ruleset is kind of dumb imo because on different rules the difference is that the problems would be much harder to balance out a longer submission window

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

    You'll never be as fast if you never participate though.

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

    Speed is an acquired skill.

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

Liked the thanking section!! where he used symmetric colour combinations.. :)

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

I registered for the contest before today's one (Specialist -> Expert) and it still says I'm in competition. Just to confirm this contest won't be rated for me right.

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

Hope pretest will be strong, not like last contest

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

Hi everyone,

I would like to know whether I can start 8 hours following the competition starting time since the starting time is past midnight for me. (I am new to competitive programming).

Thanks very much. Cheers

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

    No , if you give contest at later time than the mentioned time it wouldn't be considered for ratings . It will become a practice contest . For having yourself in official standings you must give contest at the mentioned time only then only you would be considered for standinds and rating change

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

    You can start a Virtual participation whenever you want after the contest but if you want to make your rating update you have to follow the starting time.

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

    I guess you cant participate later, but if you don't need rating, you always can participate virtual. It will be just like normal participation, but without rating. Cheers and good luck.

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

Now, finally before my exams, I am gonna compete.

And can anyone please spare a minute and tell me in which division do I belong, my rating being 814. Thanks.

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

    You can participate in any contest except those rated solely for Div. 1. This means that you can participate in Div 3 , Div 2 and combined Div 1+2 rounds

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

Is there any chance of arranging these contests so they are in the evening or weekends. Anyone who has a job can't enter as they will be working.

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

    If you prefer weekend contests, then AtCoder may be a good choice for you.

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

If I know it early, I'll not get to expert:)

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

So we penalty of 10 min on the wrong submission and not of 50 points. Right?

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

    For every minute, 5 point decreases from the main point. Like, 500->495->490. So, penalty of 10 minutes and 50 points are same

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

Good Luck to Everyone

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

o sweet lords of coding, help me reach 1200.

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

Last minute tip ! Open this to side : CF Notifications So that you don't need to wait to see AC's

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

Last minute tip ! Open this to side : CF Notifications So that you don't need to wait to see AC's

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

After so long time i'm missing a CF rated contest for my Covid. :'( Hope to come back soon.keep me in your prayer. :(

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

Oof.

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +2 Проголосовать: не нравится
A,B1 == div 3 
B2,C.. == div 2 
»
3 года назад, # |
  Проголосовать: нравится +16 Проголосовать: не нравится

A perfect div2 round.

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

A divison 2 contest with Divison 3 participants.

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

you should have said to check D2 before D1 instead of B2 before B1 I didn't get how dominoes are placed until i checked D2

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

    hey can u tell me the logic behind b2, i got what the maximum number of single colour used would be but i could not figure out how to colour them without going against the rules.

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

      any number that exists k or more times must be colored with all k colors and what's left of that number occurrences are zeroed so you need map with vector of positions of that number to do that and other numbers that exists less than k just gather their positions in one vector and color them any way

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

Thanks for the great contest :)

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

lovely problems!

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

When can I check the testcases?

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

Problem C was incredibly similar to this problem, so much so that I copied over my solution almost verbatim...

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

Perhaps you should read the problem B2 before you start solving B1.

Was this meant to be a troll?

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

This round was too hard for Div. 3

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

Well I found that pretty tough and it wasn't even meant for me

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

    Solved all but D2. Why is problem D so hard?(or maybe I'm being dumb)

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

      I decided to focus on completing D2 instead and that deprived me of the time to attempt E or F. D2 was conceptually fine but the casework and construction is very fiddly.

      Even prior to that, B2 was fine but not Div 3 problem B fine.

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

        I implemented it by assigning different integers to each domino (so casework was on integers, without considering which letter should be used for which domino). Later I processed the integer table as follows:

        • create a graph of neighboring dominos IDs (so that we know which colors are forbidden — if two IDs are connected, we can't assign them the same color);
        • notice that no domino has more than 6 neighbors;
        • this means that you can simply select any color for your domino that is not yet assigned to any of your neighbors in the graph and you will never run out of letters;

        Submission 123498750 containing the color assignment at the end of st() function.

        Changing D1 into D2 took slightly less than 20 minutes.

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

          I did something pretty similar except it was just a row-by-row construction where I incremented a value (mod 26) while it matched any of its above or left neighbours.

          Not conceptually too difficult for sure, but with the different cases (N odd, M odd) I found it a pain, and the kind of implementation that isn't great for a 2 hour contest except for the most efficient coders. But I was too committed by that stage to stop and move on. I have since seen that E in particular was a much cleaner question and had I realised what D2 entailed I would have skipped and solved E.

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

            Makes a lot of sense, thanks for the reply ;)

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

            I did something to make the casework easier-

            We know at least one of n and m is even. So we have two cases-
            1. n(rows) is even
            2. n is odd => m(cols) must be even

            In case 2, we can rotate the table by 90 degrees => n and m are swapped, and all horizontal dominoes become vertical and vice versa, ie. in the rotated configuration, k becomes m*n/2-k. So we only need to solve for case 1, and that's it. (Oh, and we rotate the matrix back before printing)

            For filling the table, filling from left to right and from top to bottom at all times worked cleanly for me. (Had only to check the top, left, and bottom-left dominoes) submission

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

    I was chatting with other people at the same time so I didn't focus. But seriously I wasn't ready for this. Without turning on my brain before the contest, I just wanted to quit the moment I saw B and D.

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

someone please hack my submission.123523305

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

    It looks fine, in my opinion it should pass the system tests ;) I tried to hack you based on the fact that you allocate large arrays statically but it passed ;) Good job :D

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

what is pretest 2 of B2 ? I was not able to figure out till the end

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

The problems were really interesting. Kudos to the authors involved! Would have been much better if this round was half an hour longer though

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

How to solve D1? I tried 3 cases. Got WA on Test 3.

Cases

Did I miss anything?

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

I submitted my solution with 22 seconds remaining. I couldnt see the verdict because the page was just loading. Now when i check in my submissions, there is no submission showing. And guess what, when i submitted it in practise it was accepted. Can i be helped??

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

B2 felt misplaced, for me B and D shoud have been swapped. Or C and B swapped. Or B, C, D reversed... whatever, I worked much to long on B2, and finally was not able to solve it.

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

How to solve B2?? I am not able to solve it

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

    I binary searched for the number of elements for each type and then reconstructed the coloring according to it. I think I overkilled it though.

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

      I don't see where binary search was required. I didn't think it was as difficult as the comments mention, but perhaps It was and I was just in form.

      I really liked problem $$$B2$$$, tbh.

      You can look up my code: 123477048

      Incase something isn't clear in the code you can ask me. But, mind you, I'm terrible at explaining.

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

    After having read the solution it is not very complecated.

    Consider f[i] to be the freq of i in a[].

    Then foreach f[i]>=k color the positions of the i in a[] with the k colors. Then put all other numbers in one big group and do the same in that group.

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

    Maintain count and position of each character in hash table, for example if array is 1 1 2 1, the count[1] = 3 and position[1] = 0 1 3.

    Create an array result filled with 0 of size n.

    Next iterate through each unique character in the hash table, now there are two cases:

    1. If count of any character >= k then that means you can paint each position containing that character with paints from 1..k, so iterate over position[character] from 0..k and fill each entry in result at position in incremental fashion, so result[ position[character][i] ] = i + 1

    2. If count of character is < k then push the positions of position[character] in an new array say leftPositions

    Now, at last, pop positions from leftPositions in size of k, and fill the popped positions in with paints ranging from 1..k, while popping in size of k, if at any time the size of leftPosition < k then stop and print result.

    Here is code to this approach: https://codeforces.com/contest/1551/submission/123471900

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

      I am doing something similar to this but failing on testcase 2, can u check it out if u can?123490522

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

        In your code, two same numbers might end up with same color, your case handling for when count >= k is fine, problem lies in your handling of when count < k.

        Consider this small case (it is not a valid test case just taking it to show whats wrong)

        a = 10 11 12 10 .....

        k = 3

        Your code may produce output like this: 1 2 3 1 ..., you see both 10's have same paint 1, that's the problem.

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

:(

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

    Why attend only virtual contest? I say, you should attend the on-going-contests as well, I suggest you not to care about ratings. Also, during the virtual contests you don't get that feel when you solve more problems than your level. Overall I say that its a different atmosphere when giving on-going-contests vs. virtual contests.

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

i got a WA on test 185 can anyone provide me with a counterexample 123529703

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

    Can you plz. elaborate your solution little bit more.

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

      The main idea is we partition the grid into as many 2x2 blocks as possible, with each 2x2 block being able to hold two horizontal or two vertical dominoes. If $$$n$$$ or $$$m$$$ are odd (only at most one of them can be per problem constraints), then we will have an extra strip on the end (the purple and brown region in the diagram). That extra strip can only be populated with dominoes in the same direction as the strip (so horizontal if the strip is horizontal, and vertical otherwise). Now, since we don't have as many letters as dominoes, we will have to reuse some, and I make sure two touching dominoes don't share the same letter by encoding same letters on diagonals, as shown in the diagram.

      I don't have the most rigorous proof for why this construction covers all cases, but the main idea is you have the wrong parity of $$$k$$$, then there's no way to evenly fill the grid without having a gap in the end that a domino of the opposite orientation cannot fill. On the other hand, if the parity is correct, this construction covers it.

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

You shouldn't make this contest so hard simply because DIV1/2 participants participate as well..

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

Isn't this output that my code generates for B2's sample input correct? Showing WA on test 1

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

why is this submission for E giving WA 123523281 on test case 5 I constructed a

$$$dp[i][j]$$$

whose states describe that we have arrived at i th point in the prefix with j moves done. To do that I first precalculate the

$$$pre[i][j]$$$

which says the number of elements in the suffix

$$$i,i+1,...,n$$$

such that the elements after the ith index (including i) have

$$$a[i]-(i-j)=0$$$

, i.e. we have done j moves and after that j moves the number of elements which are now standing at the required index. Now we can iterate over the moves done and check if

$$$dp[n][j]>=k$$$

and return the minimum j . please help if you can? The transitions are as follows

$$$dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+pre[i+1][j]-pre[i][j-1])$$$

second transition is as follows you deleted at the ith index. so

$$$pre[i+1][j]$$$

calculates the new sum that should be added now that we have made j moves and only the index after i is affected as the left shifts happen from these indices. Final number of elements which are equal given that we have made j moves are in

$$$dp[n][j]$$$

and now we can simply iterate over j from 1 to n

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

    I did exactly the same, except my dp[i][j] is the maximum good indices considering a prefix of length i with j elements kept.

    The transitions are much easier:

    $$$dp[i + 1][j + 1] = max(dp[i + 1][j + 1, dp[i][j] + (A[i] == j))$$$

    and

    $$$dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])$$$

    (A is 0-indexed and every element is subtracted by 1 beforehand).

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

    Also I don't think the pre thing is needed.

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

    Hey I have exact same solution as yours. You can look at the implementation here. 123524901

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

happy thing: accepted (during contest)

sad thing: accepted (1 minute after the contest)

worse thing: unfortunately, your solution of problem X has been hacked

worst thing: wrong answer/time limit exceeded in test set X (main test)

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

Did anyone solve D with DP ? I used dp on columns for each two columns c and c + 1 I may put [0, 1, 2, .., min(n, k)]

they will be placed greedily from top to bottom on column c and c + 1 and the remaining cells on c and c + 1 will contain only vertical dominos, if c == m — 1 i can only place vertical dominos on c;

I really don't know why this works, but I have intuition that when placing the horizontal dominos they can form some kind of connected block, and hence I can try different shapes for this CC

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

Is it only me Or B2 was harder for it's position?

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

In today's contest , problems were great but time was less and problems were more.

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

Trollforces

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

Two contests ago I reached expert so this was unrated for me, yet I was only able to solve A and B1. Clearly I still don't deserve my rating

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

Help needed! There is something wrong with my lambda expression below, but I have no idea why it turned out this, from my point of view, both a & b is in the range of [0, n), but it can be some invalid value, more exactly in this code, when n >= 17, it would be a mess. I would appreciate it if anyone could help!

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<int> sz(n), r(n);
        for (int i = 0; i < n; i++) {
            r[i] = i;
        }
            sort(r.begin(), r.end(), [&](int a, int b){
//                 cout << "a = " << a << " b = " << b << '\n';
                if (a < 0 || a >= n || b < 0 || b >= n) {
                    cout << "@" << a << ":" << b << ":" << n << '\n';
                    return false;
                 }
                return sz[a] <= sz[b];
            });
    }
    return 0;
}

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

    I have no idea about "invalid values" but you should never use <= or >= in custom sort comparator.

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

      Thank you so much! I change the '<=' to '<', the annoying value disappeared! But why? Is it a property of the lambda expression?

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

        No, it is not related to lambda.

        Take a look at the parameters part of https://en.cppreference.com/w/cpp/algorithm/sort and the requirements of a comparator https://en.cppreference.com/w/cpp/named_req/Compare .

        Always keep this in mind.

        I have no idea what will happen exactly if you use <=, (I assume it is a UB — undefined behaviour?) but UB always leads to disaster.

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

Problem D2 reminded me of this problem if anyone wants to try.

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

Problem E was very similar (though not identical) to task from XIV Polish Olympiad in Informatics: statement in Polish

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

How are the multiple answers tested?, like in today's B2

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

Hi ! I encountered something weird in my submission for todays 'C'.

Firstly I have made a 'vector of vectors' which store the property of each string i.e. the number of a's,b,c,d,e. Then while checking for character 'a', I am sorting this 'vector of vectors' according to the difference between count of a's and rest of characters.

Driver code

But this is getting RTE in the comparator function:

Comparator

While Debugging for Test case 2, 2nd test.. I found that the size of 2nd vector passed in the comparator is coming out of be 0 at one stage (but all the vectors in my 'vector of vectors' are of size 5), and obviously RTE is generated there ..

Can somebody tell more about this ambiguous behaviour ? and how to correct it ( while using the comparator function only )

PS: In Comparator i have passed as vector<ll> &v1 only idk why it's showing vector&v1 here. Also my complete code is very ugly, so that's why am only putting snippets here !!

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

How are the multiple answers tested?, like in today's B2

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

    Put every colored element in a set. Let's say that in correct solution the size of each color's set is n, now check for the given output if the size of set is equal to n and there are no repeated elements.

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

How to solve C ?? I am not able to solve it.

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

    Let's define how interesting a given letter in a string as follows:

    • The number of occurrences of a given letter $$$-$$$ the number of occurrences without that letter. Let's call this value $$$x$$$.

    For example, in the string $$$bac$$$, $$$x_a$$$ would be $$$-1$$$ because $$$a$$$ occurs once and the number of non-$$$a$$$ letters is two. $$$1 - 2 = -1$$$.

    Another example is $$$aaada$$$, $$$x_a$$$ would be $$$3$$$ because $$$a$$$ occurs four times and the number of non-$$$a$$$ letters is one. $$$4 - 1 = 3$$$.

    We can find how interesting a given letter is for each letter $$$a, b, c, d, e$$$ and find the longest subsequence with a sum greater than $$$0$$$.

    This is equivalent to finding the longest subarray with a sum greater than zero when sorted.

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

      Why is that equivalent? Any intuition?

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

        Well, greedily, we're trying to find the maximum subsequence sum, and when we sort it (in descending order), the largest elements in the array come first (obviously).

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

Can problem A be solved using binary search?

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

can someone kindly tell me why am I getting a TLE in this code for problem B2 ? It will be very appreciated..thx 123532079

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

    You are getting TLE because it is taking a long time to parse such big preprocessor statements. Upd: Oh you removed your unformatted code from the comment lol. The actual reason is allocating array of size 2e5 in each test case and there can be upto 1e4 testcases. So you're taking time for allocating arrays of size 2e9. This will TLE.

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

This is not the div.3 we wanted but this is what we needed.

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

Is there any way to get all test cases? My program for B2 constantly crashes on test 2 case 3901 and I have really no clue what's going wrong. 123544433

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

    You have to use if conditions, its not pleasant but it works if the input is not too large. run your solution for test case 1, then for test case 2 print the input for T=3901 for others just take input and don't print anything.

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

    Check my submissions for B2 where i printed the failing tc for 3901 ( using your code )

    8 4

    4 5 4 3 5 3 3 3

    Your Ans: 1 1 2 2 3 3 4 0

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

Can anybody helps me with my code in E it gives WA on test 4

code: https://codeforces.com/contest/1551/submission/123549241

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

Any ideas for F?

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

    If k = 2, you can pick any 2 nodes so answer is nC2. For k>2

    Let's say we can pick k nodes such that each node has a distance D with the other. Since all of these nodes are equidistant from each other, and the number of nodes is >=3, this has to be a star formation with one "unselected" node at the centre, and all the selected k nodes are equidistant from this centre (distance of D/2 to be precise, D can never be odd). Let's call the centre X. Let's root the tree at X.

    Also note that, any 2 selected nodes will have LCA equal to centre (meaning any path from one selected node to the other must go through centre, otherwise their distance will become shorter). What this means is that from the subtree of each child of X, only one node can be selected. If the number of children X has is <K , we can't select K nodes as the question states. If it has more children (C is the number of children X has) -

    Do dfs from each child of X and for a height h, let's say there are n1, n2, n3 ... nC nodes at height h in each child-subtree respectively. Since from each child-subtree, we can only select 1 node. The task becomes selecting K nodes (one from each child) given the above information. This can be done with dp.

    DP[a][b] means the number of ways we can select b such nodes (at max one from each child-subtree) from the first a children.
    
    DP[a][b] = DP[a-1][b] + na * DP[a-1][b-1]
    // Don't select a node from ath child + Select any 1 among the na nodes from the ath child.
    
    ans += DP[C][K]
    

    Looping over the root node X and height H and then solving the dp for each such combination yields the final result. You can look at my code, but my implementation is a bit messy with some extra code.

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

Finger crossed,for not to repeat last round hacking drama & to be specialist for the first time which missed yesterday due to hacking drama

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

    It's not a drama. You had an incorrect solution for which you were rightfully penalized!

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

      Yes, but it was massive for two problem, problem b was hacked/failed maintest about 3k and for problem D it was about 1.8-2k. Total standing was changed!

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

Only 4 different characters are needed in D2: 123522856

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

editorial?

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

can anyone give hint for C. thanks in advance :)

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

Can someone kindly tell me why am I getting TLE in this code for problem B2? 123566277. I really don't know why it get TLE T_T

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

    in every testcase you are initializing 2e5 memory ..may be thats why..you don't need to because ai<=n

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

How long does it take to update the rating?

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

    Come on, man. We can literally see that this is not your first Div.3 round. Why these useless comments?

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

i must say this wasn't div3 contest , problem C was tough for me.

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

Thanks for Round!

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

To not keep you waiting, the ratings are updated preliminarily. In a few hours/days, I will remove cheaters and update the ratings again!

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

Спасибо за раунд!

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

Can anybody help in memoizing this recursive code for problem E since I get TLE: Problem E

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

    I don't think it is memoizable considering the recursive function has 6 dimensions. Try optimizing this and bring that 6 down to a 2.

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

please share hint for C.

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

please share hint for C.

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

Внимание!

Ваше решение 123450555 по задаче 1551A значительным образом совпадает с решениями других участников и находится в группе одинаковых решений rkarroy/123446796, oxxyumoron/123450555. Такое совпадение является явным нарушением правил. Отметим, что непреднамеренное утечка тоже является нарушением. Например, не следует пользоваться ideone.com с настройками по умолчанию (публичным доступом к вашему коду). Если вы имеете неоспоримые доказательства, что совпадение произошло по причине использования общего источника, опубликованного до соревнования, то напишите комментарий к посту о раунде со всеми деталями. Подробнее можно прочитать по ссылке http://codeforces.com/blog/entry/8790. Такое нарушение правил может являться основанием для блокировки вашего аккаунта или других штрафных санкций. В случае повторения нарушений, ваш аккаунт может быть заблокирован.

Здравствуйте! Я писала свой код на личном компьютере, в среде разработки. Возможно, решение совпало с чьим-то другим из-за своей простоты. Я ни с кем не общалась во время раунда, никому не отправляла код. Можно ли что-то сделать, чтобы такие ситуации больше не повторялись? Спасибо!