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

Автор tibinyte, 4 недели назад, По-английски

Hello, Codeforces! Or, as we like to say in Romania: Sus Sus Sus, ca la Strehaia tată!

I am glad to finally invite you to participate in Codeforces Round 875 (Div. 1) and Codeforces Round 875 (Div. 2), which will start on May/28/2023 17:35 (Moscow time). In both divisions, you will be given 6 problems and 2 hours and 30 minutes to solve them.

The problems were authored and prepared by Andrei_ierdnA, Doru, Gheal, IacobTudor, LucaLucaM, RedstoneGamer22, SlavicG, Sochu, alecs, andrei_boaca, andrei_iorgulescu, lucaperju, valeriu and me ( tibinyte ).

I would like to thank:

  • irkstepanov for further help with logistics of organization.
  • freak93 for no morning refreshment.

Scoring Distribution

  • div 2: $$$500-750-1250-1750-2500-3000$$$

  • div 1: $$$500-1000-1750-2250-3000-3500$$$

The editorial has been published here!

And here are our winners!

# Div 1 Div 2
1 Ormlis kotrin
2 1a2b3c4 CLOCKS_PER_SEC
3 dorijanlendvaj IHatePaiu
4 tourist Lihwy
5 Radewoosh VietCek
  • Проголосовать: нравится
  • +525
  • Проголосовать: не нравится

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

As a non-newbie, I miss being newbie :(

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

    As a specialist tester, i specialist tested.

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

    yo teach me your ways

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

    This may be a way of speaking for the question group. They may be saying this in another way to wish us a better ranking!

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

    as a newbie, i wish i will become like you

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

As an average tester, I average tested.

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

As a bad tester,I tested like good tester.

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

didn’t Mike say you can’t put the wrong colors for usernames?

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

sus

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

As a setter, I didn't test.

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

Cringe! Just make regular announcements

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

I am a simple man: i see pepe the frog, i upvote the blog

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

Why so few authors? What happened to the rest?

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

    We were asked by the Codeforces admins to shorten the author list.

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

Wasn't everyone's name colored grey initially? What happened?

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

Only 14 authors :D

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

As a pupil,IDK why I like to watch grand masters.

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

All problems are tricky but good!

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

OMG PEPE EMOJI!!

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

Kind request to question setter. Please try to keep,

1) questions are balanced,

2) different topics ( rather than one single topic ),

3) cover largest input and longest run time test cases and yet keep one or two edges cases so contest could be fun with hacks.

4) give clear explanation for the example test cases.

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

    " keep one or two edges cases so contest could be fun with hacks "

    Its not fun for the guy who gets hacked.

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

      true. but it gives you the feeling like ICPC.

      You may think that you have solved problem, but it could fail final system testing.

      Also, when we have left very little time left and we cant solve/implement problems anymore, it is good to try to hack.

      UPDATE :

      There is some misunderstanding, I failed to clearly pointing out that hacking and ICPC aren't related. Personally I find weak pretests or excluding edge cases very enjoying. Also, if pretests are passing, then there should be some suspense whether final system test will pass or not ( like an ICPC ) .

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

        Feeling like ICPC? Who told you that there is system testing in ICPC?

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

          adityagamer , I dont know if they changed it recently or not.

          But this is what I know about ICPC finals,

          https://youtu.be/kIbgLrquTx4?t=31411

          https://youtu.be/15Wyj_-PG9I?t=30869

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

            That's not hacking. The scoreboard is frozen near the end of an ICPC competition. Those clips show the scoreboard being unfrozen after the end of the contest. The yellow submissions are ones that were submitted in the last hour when the scoreboard was frozen.

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

              I didn't say its hacking. I said, some of the submissions could fail final system testing, if edge cases are not considered in pretests. adityagamer said, there is no system testing in ICPC, but I guess, there are few pending problems which are done tested after the contests.

              All I am saying is,,, there should be some suspense after the pretests, whether the final system testcases will pass or not.

              Of course there is no hacking in ICPC, I never said There is hacking ICPC.

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

                Please reread comment above and stop being annoying. If you're unable to see that there's no "system testing" in ICPC (it's clearly explained in Erekle's comment) then don't even start/continue conversation.

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

                man got 300+ downvotes from a single comment thread

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

                  ratings or downvotes, does it matter ?

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

                  to some extent, yes (30%) for me

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

                  great thinking, rating and contribution don't matter on codeforces. Contribution doesn't since it's ratist community and rating doesn't since you get nothing to show for it

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

    We've started working on the round over half a year ago and we most likely won't be making radical changes one day before the start of the round.

    I hope you enjoy the round regardless :thumbsup:

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

      Yes agreed. makes sense, not to change testcases-files or any other critical data.

      But, problem statements could be changed ( for better understanding, or test cases explanations could be changed )

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

        Are you implying that we made a conscious effort to make the statements hard to understand?

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

    Do you really think that you are giving something new for community with this comment? You are just saying obvious things.

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

      1) Do you really think that you are giving something new for community with this comment ?

      No, I am not giving SOMETHING NEW , but I am reminding something which is OLD AND GOLD, which recently most of the question setters have forgotten in past consecutive contests.

      If these things are obvious things, then why question setters are not doing what is so called OBVIOUS ?

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

        If these things are obvious things, then why question setters are not doing what is so called OBVIOUS ?

        You will understand it by yourself just when you will become a problemsetter. You advice is just "make a good contest, please". It is obvious.

        For example, the balance of a contest is subjective and thus cannot be measured by authors and coordinators. One need dozens of testers to make a balanced round.

        And also. Imagine you have a slightly unbalanced round. What will you do? Throw away one or two tasks and try to come up with another tasks?

        Your problem is that you think that coordinators or problem-setters are incompetent in some way. It's better to try to approach your questions in another way: why the rounds are like they are now? Which things I don't know and don't understand about problemsetting?

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

    All the best to heard-mentality-crew... have positive delta... xD

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

The contest clashes with the leetcode biweekly contest 105. Please do something about the timing :)

Update

As I can see my comment has initiated a spread of hate towards a certain platform in the thread, I would like to clarify that we live in a world of free will, thus anyone can opt to give either of the two contests according to their preference. I'd myself choose the codeforces contest due to the better quality of questions. My comment was only intended to make the round makers aware of a clash between the two contests and nothing else. Finally to everyone, who blindly downvoted my comment due to their specific hate for a platform just shows their herd mentality. Rest I hope for everyone to have a great performance in the contest.

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

As grey. I hope be specialist next round uWu

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

As a <newbiw i wants to give the round

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

As a participant, I like participating.

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

leetcode biweekly + div2 both tomorrow. But everyone gonna choose div2...

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

omg grey round!

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

longest duration contest 2:30 hr.

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

Can anyone please give me advise? how can I practice hard problems(like 1600+ rating) so that i can solve problem D,E within the contest time? I am trying to up solve but feeling so hard. What strategies can I follow? Thanks in advance.

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

I completely ignored the fact that the blog writer has a -14 rating

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

Wow! A negative-rated author! Hopefully, enjoy this round (❁´◡`❁)

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

As a contestant, i am waiting...

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

What is "Scoring Distribution: TBD"?

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

Good Luck for everyone

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

vuw

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

Sniff sniff, i smell AmOnGuS!!!

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

Is this Div2 rated for participants with rating < 2100 ?

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

    You can only participate in div 1

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

    isn't div. 2 open for CM? It's neither a combined round

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

      Yes. A CM can participate in either div2 or 1 and have EDU round rated for them.

      Edit : But not in a div 2 within a separate div 1 — 2 round unless he registered when he was still expert.

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

      For rounds with separate Div 1 and Div 2, CM can only participate in the Div 1 round

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

        Are you sure about this? I usually see CMs profiles and have rated div2 in contests history even after being CM. Anyways, I registered for the div2 when I was still blue

        Edit : Upvoted. I think you're correct. I had a look over some random pages of the common registrants for the div2 and I rarely found a CM registered. The ones registered did so when they were yet expert.

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

        whaaa.. What's your source for that?

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

          Based on at least 100 or so rated rounds in the past two years, and also if you check the scoreboard for the Div 2 rounds that had an accompanying Div 1, there are no CMs. IIRC, Mike or other system managers manually removes CMs from the Div 2 registration or smth.

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

            thx for your reply. This seems highly confusing and inefficient. I bet it'd make waves but ffs make CMs div. 1 or div. 2 only

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

damn where scoring distribution? is it soo hard to publish it at least 1 day before the round? why almost nobody does that now...

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

    Don't know why, but I never care about scoring distribution O.o

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

      Same. Still, a bit strange to not see it one day before the contest. The authors have been preparing the contest for months, why couldn't they use a few minutes to write the points distribution?

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

Always welcome weekend rounds :) First rated contest for me in a long time.

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

good luck everybody!!!

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

Anything is possible if you put your mind to it :D

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

Timing clashing with Leetcode Contest :(

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

Maybe I won't be allowed to wait until summer vacation, let's go tonight!

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

who let a negative rated guy set problems 😡

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

Is this round is rated?

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

Good luck everyone!

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

I hoep everyone will get good marks in this contest. Good luck!

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

MikeMirzayanov please postpone this contest , today is IPL final , Probably dhoni would be playing for the last time today and everyone wants to see him. Please Postpone the contest Gheal

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

    set your priorities straight. Mike and the codeforces team isnt here to please everyone with their contest timings and the contest will not be rescheduled for such petty reasons

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

    Finally BCCI postponed IPL

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

    CF>> IPL, even god postponed the IPL Final to today so that we can enjoy both!

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

RescheduleForces!

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

(()def()r(es??again?

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

Please, if the round is postponed also this time, try to tell it earlier

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

Good luck

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

I'm crossing my fingers and toes, hoping I don't plummet from my precious blue rank in today's game. It's a delicate balance, you see—I'm teetering at a hilariously precise 1601 points. Wish me luck!

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

CSK match >>>> CF contest :) feeling sad because not going to participate in this round

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

Best of luck to me :)

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

I was registered for the contest when I was an expert. But I just noticed that I am a candidate master, but registered for div2. I think it would be better if the system would inform you about this.

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

Just as former world champion Magnus Carlsen won the recent chess tournament and came back again at the top, tourist(Gennady) should also try to get his first position back today :)

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

+76 is needed for CM. is it possible??

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

Problem B be like, you hurry up & I'll give you a penalty! :)

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

tourner dans le vide

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

Problem B is s*ck

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

FSTs loading...

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

nice round,but i forgot something and got lot of wrong:(

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

Div 2 contest exists Easy ass permutation problem be like: Did you miss me?

XD

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

Really dissapointed by B problem (Div. 1). There is 4 sec TL, and my $$$\mathcal{O}(n\sqrt{n})$$$ solution with hashmap doesn't pass. I tried to optimize it many times, using fast hashmaps, different pragmas and other methods.

Judging by standings I can conclude that I'm not the only one with this problem. But some people have achieved +5/+10/+20, others not.

TL 4 sec implies that $$$2 \cdot 10^5 \cdot 650 \cdot [hashmap time] = 1.3 \cdot 10^8 \cdot [hashmap time]$$$ will pass!

If author's solution has another complexity TL must be 1sec. If author's solution is just 2 times faster for example you can't ban people with $$$\mathcal{O}(n\sqrt{n})$$$ solution — this is not Codeforces politics.

So, AB were good tasks, C was interesting too, but I just waste all time to speed up B, it was terrible round.

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

    just don't use hashmap lol

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

      I have ML without it

      I need $$$[650][2 \cdot 10^5]$$$ array of $$$32$$$-bit integeres. This is $$$4$$$ byte $$$\cdot 650 \cdot 2 \cdot 10^5 = 520000000$$$ byte = $$$520$$$ MB.

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

        Since j < SQ in your solution, you can create an array int[SQ][n+1]. Just don't access the array if the second value is not in the range [1, n].

        Also you only need to clear n elements between test cases. Here's my submission: 207611902.

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

    I spent around 1 hour switching between unordered map, gp_hash_table and cc_hash_table and trying various optimizations to remove TLE and MLE :/.

    In the last 5 mins, I replaced it with a binary search on a vector containing deduplicated pairs, and their count and got pretests passed, though I still expect TLE during systests.

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

    Sometimes it is faster to just use regular (tree) map and check whether the element exists in the map before accessing (avoids unnecessary insertions). Not sure if this was intended though.

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

    Is it still possible to increase the time limit and rejudge submissions at this point? I'm another affected participant who tried messing with unordered_map and stuff which didn't work, while some solutions that just used binary search instead of map (207592515, for example), which should have the exact same complexity, passed.

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

    Try a stronger hash function

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

    lowerbound in vector works faster than hashmap in this kind of problems, from my experience

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

Decided to optimize D at the last second(after 1hr of being indecisive XD), it changed runtime from 3700 ms -> 1700 ms. But idk if it's actually just weak tests. Try hacking it 207664263. This problem would probably have many TLEs.

UPD: Turns out the initial 3.7s solution TLEd, but this one still passes in 1.7s

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

How to solve B div1/ D div2?

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

For the problem C do we have to use DFS? If anyone have use DFS to solve please can you share submission link.

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

div1 B too easy to come up with a solution but constraints too bad, it spoiled the contest for many people. Almost solved d1C, i think, could smb please write the solution? wanna check if mine is correct

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

    I am not sure about B constraints, I wrote the first thing which came to my mind and it passed in 2.1s. It's not optimal, surely it can be easily optimized to 1.5s and probably to <1s with some effort. But tbh I am not completely sure it will pass systests, I did not prove complexity. Upd: passed systests in 2.1s

    Regarding C, I did not solve it but I think one of the important insights is that any 2 intersecting (but not nested) segments [A;B] and [C;D] can be replaced with 3 non-intersecting segments [A;C) [C;B] and (B;D]. Then we can somehow remove all intersecting segments and solve a much easier subtask where segments can be only nested (build a tree from them).

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

    Yea I'm kinda bummed out because for d2D/d1B I had a java solution early on that got TLE, and I tried a lot of things but just couldn't get it under the TL. Then I converted the same code into c++ (which I barely know) and it passed, but by then I already wasted 1+ hours.

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

Can anyone tell me what is wrong with my code for div2C (sorry its java lol): https://codeforces.com/contest/1831/submission/207667860

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

Great Contest! If you are stuck on Problem A, Problem B, Problem C (Div2) then this editorial might be helpful: link

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

how to solve D?

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

    idk

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

    you need to use the fact that the values of a[i] and b[i] are less than "N".

    So, for each pair (a[i],b[i]), we have to traverse till sqrt(N) at max, and see if the reverse pair exists or not.

    first of all, shard the pairs(a[i],b[i]) based on the first value (a[i]). Also sort each shard for applying faster search operation using binary_search.

    We also need to keep track that how many times particular pair has been encountered in past, to do so we need a map < pair <int, int > , int > where map[(x,y)] denotes, how many times particular pair (x,y) has been encountered yet.

    for(int i = 0 ; i < n ; i++) {
       shard[a[i]].push_back(b[i])
    }
    for(int i = 1 ; i <= n ; i++) { // sort each shards
       sort(shard[i].begin(),shard[i].end())
    }
    // suppose shard pairs are (1,2),(1,3),(2,3),(2,1),(4,8),(4,12),(4,4)
    // shard[1] = { 2 , 3 }
    // shard[2] = { 1 , 3 }
    // shard[3] = { empty , because no pair has a[i] == 3 }
    // shard [4] = { 4 , 8 , 12 }
    // Hope part 1 is clear...
    

    Core logic part is here now, suppose (a[i] , b[i]) and (a[j] , b[j]) are expected pair, then we will a[i] * a[j] - b[i] = b[j] , for better understanding I will use (x,y) and (p,q) instead of (a[i],b[i]) and (a[j],b[j]) from now on. so, (x*p — y == q) must hold in order to count the pairs.

    if shard[x] has value 'y' in it, that means, we have a pair (x , y) somewhere. Now, any pair (x , y) and (p, q) to be in the answer, we must make sure that x * p <= 2*n, otherwise answer is never possible ( because of the restriction that 1 <= y <= n && 1 <= q <= n,,, their sum will be 2 <= y + q <= 2*n. ) , that's why x * p must be less than 2 * n ;

    So, now using above facts, please go through code,


    for(int i = 1 ; i <= n ; i++) { for(int j = 0 ; j < shard[i].size(); j++) { int x = i; int y = shard[i][j]; // now assume that p is 1,2,3... until p * x <= 2 * n; for(int k = 1 ; k <= n ; k++) { if( x * p > 2 * n ) break; // here answer is never possible, // Now, try to find in shard[k], whether the value x*p - y is available or not // to do so, we can use binary_search, or set, or lower_bound() or anything auto it = lower_bound(shard[k].begin(),shard[k].end(),x*p-y); if(it != shard[k].end() && *it == x*p-y) { // Condition to see if the x*p-y is present or not // if the current value is present, then we have to add it number of times it has been encountered till now, ans += map[(x,y)] } } // once we have processed a pair (x,y), // we also have to add it to our map of encountered pairs map[(x,y)]++; } } // finally return ans, dont forget to initialise it with 0 by the time declaring it. :) . } Final complexity is O (N log N) + O(N * sqrt(N) * log N) in my case of implementation. With unordered maps and more further optimisations u could reduce log N factor to O(1) in the second part. but that's unnecessary to get AC.
    • »
      »
      »
      47 часов назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Wow, thanks a lot, pretty cool solution. I was close to it during the round, but wasn't able to write exact solution

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

Edit: Oops, forgot checking by [] creates the element if it isn't already present. These unnecesary inserts and increase in query time due to map size probably leads to a 2-3x increase in running time leading to TLE.

Does gp_hash_table really use $$$\gt 500MB$$$ to store $$$2 \times 10^5$$$ elements????

gp_hash_table to store pairs (207666127) -> MLE

binary search on vector of deduplicated pairs (207666127) -> AC with 10KB memory usage

Also is there a faster than $$$O(n \sqrt n \log(n))$$$ solution to Div2D / Div1B? I spent like 1 hour optimizing it to remove TLE and then MLE T_T.

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

    $$$b_i\le n$$$, so you only need to maintain a bucket with size $$$n$$$

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

      Oh so since $$$a_i \leq \sqrt{2n}$$$, you just maintain a $$$\sqrt{2n} \times n$$$ vector for counts which fits in around 500MB of memory?

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

        no, you enumerate the a_i which is $$$\le \sqrt{2n}$$$ (assume that is $$$v$$$), and you only need to maintain a bucket with size $$$O(n)$$$ (which is also $$$O(n)$$$ in memory) to calculate the occurrence of $$$va_i-b_i$$$. After that, you clear the bucket.

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

    Every time you search in a map / unordered_map, if value you are searching for is not present, it always creates new element for it. So it is $$$O(n\sqrt{n})$$$ memory if you use them.

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

I do think there's no need to set the memory limit to 256MB instead of 1024MB. It is trivial to optimize the memory of knapsack on tree to $$$O(n)$$$ my storing the dp values into the return value of dfs.

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

What is second test case for D?

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

Is it possible to solve F by SMAWK + persistent segment tree?

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

Confusing Round. C is a good problem.But B is just a Trash.

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

As an average coder, I average code, but I'm not average here.

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

with the whole army of testers and setters the pretests are still this bad + stupid constraints.

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

Had the new idea in the last 15 minutes. My heart can't handle this.

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

How to solve div2 C?

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

Finally a good contest and not Speedforces. B was so time-consuming tho.

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

Judging by the number of people upset over Div2 D(Div1 B), I doubt the editorial would be satisfying(though I expect to learn something different/new). Still would love to know any approach that worked for you guys. Was stuck on this problem for 2 hours :(

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

    My approach was to split everything into buckets by A. Then we need to iterate through small buckets (A <= sqrt(MAX*2)) in an outer loop because otherwise, a*a will be too large and iterate through all buckets in an inner loop.

    At each iteration, calculate the answer for pair of buckets. To do it efficiently, sort elements in buckets, and use the smaller (by the number of elements) bucket as a needle and the larger as a haystack, do a binary search to find the number of matching elements.

    Also, we need to match every A <= sqrt(MAX*2) bucket with itself but it is fast so can be done in a variety of ways.

    I think my submission 207627709 is pretty clear but I am not sure if it was the supposed solution. Passed in 2.1s, probably could be optimized to 1s.

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

      I thought about the exact same optimization during the contest but wasted too much time trying to prove its worst-case time complexity. Here is my submission 207739872 after the contest. I still haven't figured the time complexity part yet. Do you (or someone else) have any insights?

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

Don't know why but I thought that there will be edge from u to v and not from v to u and treated the graph like a directed graph which resulted in a bad contest

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

This is the moment that I am very nervous about system testing. I solved problem div1 C in the last minute. If any of the div1 B and C passed, I will reach master! Please, don't FST, don't FST, don't FST.

ranking

UPD: I passed B, and I will reach master.

UPD again: Yes !! I passed C. In my estimation, problem 1C problem have a difficulty of at least 2300, and this problem will be the highest rating problem I have ever solved in contest.

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

in problem C , my idea was build a normal tree, and if there in a level at least one node that became upove the parent I increase (reading) by one . is this idea wrong ?

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

Seems that many people passed pretests on D with 500MB of memory (me included). Could it have been a good idea to increase the memory limit to 1024MB instead?

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

    That might've been an unintended solution, in which case the memory limit should've been 256 MB. I also passed Div.1 B with 506 MB, just hoping for no FST (although it seems very likely)

    UPD: Luckily I didn't FST. Although I believe that the solution might be hackable.

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

      Well, the editorial solution seems to use the same idea as mine, maintaining a large 640x200000 array. I don't know much about memory but it should probably use a similar amount, unless arrays use up significantly less memory than vectors.

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

        Afaik, arrays don't use (significantly) less memory. I realize now that my comment doesn't really make sense — I didn't notice that the editorial was already published.

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

14 people dedicated their lives to CP. 14 people prepared this round. 14 people. 14. AND IT IS STILL A TERRIBLE ROUND.

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

for me , problems C<A<<<<<<<<B

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

so angry with myself. I messed up on B and then was too late for everything else. I was allocating an array of the max size so I got always TLE without figuring out why for more than an hour...

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

B was very bad for me.

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

Yeah, solved 1830B - The BOSS Can Count Pairs in $$$O(n^2)$$$. Solution

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

    OMG

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

    What? How did this pass?

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

      This solution has been optimized by GCC after applying auto-vectorization for type float in a for-loop (FMA instruction set), in other words the for-loop has been parallelized on low level by processing $$$8$$$ floats per one iteration (SIMD — Single-Instruction-Multiple-Data), because iterations of for-loop are independent.

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

        Could you share any resource for the same?

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

          _aka5h, Elagamy, I read two articles: «A Guide To Vectorization With Intel C++ Compilers» and «GCC Autovectorization — A journey throught compiler options, SIMD», then experimented on old codeforces problems (most of them has limitation $$$n=100000$$$ or $$$n=200000$$$ and you can try to solve it). Also I used godbolt.org to see assembly. Maybe I read some other blogs from first pages from google, but I don't remember it.

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

    I think you should become a tester.
    To make sure that unintentional time complexity doesn't pass.

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

      The dilemma is a tighter time limit might've made the constraints so restrictive that even a fairly well written solution with the right time complexity would receive TLE verdict (especially in a language like Python or Java).

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

    wow it's a great optimization,How to learn the performance of interacting between CPU and memory ?

    I've learned about instruction set like this, but i want to know how to benefit from this knowledge in the coding paradigms?

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

How to approach D ? got stuck , but couldn't think anything in linear time

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

For problem D, I am having difficulty thinking of a solution with less than O(n^2) time complexity. How should I approach this? For the entire duration, I was thinking of leveraging the fact that the sum of two elements can be at most 2*n and was not able to think of anything else. So far, I have only seen people using fancy data structures which I have never heard of.

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

Might cross 1700 today for the first time in my CF journey 💙. I'm lucky that the contest was rescheduled because my internet connection was terrible yesterday.

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

please guide for B div 2

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

    It's a little hard to explain, but my code should be ok to read. We are essentially finding the longest "streaks" of the same value from each array. Then taking the max of sums each one. (Say if there is a streak of length 2 with value 3 from A, and a streak of length 5, with value 3 from B, we just add 2 + 5, and take the max over all of these values values). Its (kinda?) easy to see that the longest streak in array "C" will be comprised of one subarray from A and one subarray from B.

    Proof that we can do this: We can greedily remove all values before the two subarrays. then merge the two subarrays together. (try to prove it to yourself through simulating it)

    https://codeforces.com/contest/1831/submission/207591101

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

    suppose a[] = [_ _ _ _ x x x x _ __ _ _ ] b[] = [_ _ x x x _ _ _ ]

    You need max length subarray of equal elements

    for this you need a subarray from (array a) and a subarray of same element from (array b) and concatination of both will contribute to ans

    at last ans will be max of both subarray length

    fr(i , n) { lli val = v[i]; lli cm = 1; lli j = i + 1; while(j < n and v[j] == val) { cm++; j++; } i = j — 1;

    temp1[val] = max(cm , temp1[val]);       
    }

    // storing subarray of equal element size in temp array at particular index of that element

    // same for both array a and b at last finding max of both size

    lli ans = -1; fr( i , n + n + 1) { ans = max(ans , temp1[i] + temp2[i]); }

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

GreatForces

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

C was fun.

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

How to approach problem 1831C - Copil Copac Draws Trees ?. Got TLE while solving using Queue 207622849. Couldn't figure out why it is getting TLE.

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

for today B problem i am understanding something wrong

  1. 1 1 1 1 3 2 2 2 2 — -
  2. 2 2 2 2 3 1 1 1 1-- for this i have checked output of users you have system test passed as ans 8 but which merging will lead to 8 as a answer. I am not getting. Maybe i am understanding something wrong.
  • »
    »
    2 дня назад, # ^ |
    Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

    We can merge like this:

    1. 1 1 1 1 3 2 2 2 2
    2.                   2 2 2 2 3 1 1 1
    

    There is a segment of eight 2's in the middle.

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

      what if this
      - 3 1 1 1 1 3 2 2 2 2 3
      - 3 2 2 2 2 3 1 1 1 1 3
      what should be the answer.? according to me 4 i am not seeing largest subarray of equal elements

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

        We can get 8:

        1. 3 1 1 1 1 3   2 2 2 2         3
        2.             3         2 2 2 2   3 1 1 1 1 3
        

        Again, there is a segment of eight 2's in the middle.

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

          thanks a lot . got it .
          I cannot see that we can combine every segment of a array with b array. sorry if my doubt seems silly to you

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

    Yes, you simply needed to count the largest number of consecutive occurrences of each number in each array separately and take the maximum sum of those sums for each unique number.

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

Does the third question of div2 requires some knowledge of tree or it can be solved normally wihtout trees,as soon as i saw tree in the problem statement i left

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

    There should be some basic knowledge of tree to understand the problem statement properly. but this problem can be solved using DFS.

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

    Things you should know about tree to solve Div2C:

    • tree contains $$$n-1$$$ edges, where $$$n$$$ is the number of vertices
    • tree is connected graph without cycles
    • there exists exactly one path from some vertex $$$v$$$ to some vertex $$$u$$$
»
2 дня назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Missed the contest but my ratting saved from going down :p

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

Great Contest, learnt something new in BFS 1831C - Copil Copac Draws Trees

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

Problem C — BFS-like solution:

I keep 3 sets: written, processed and current_edges.

written: Nodes that are written at the moment, but not fully processed

processed: Nodes that are fully processed.

current_edges: edges that are going to be processed.

Also, per each node, I keep a set of edge pointers.

  • At the beginning of the solution, add 1 to written set.

  • While there are nodes to be processed, keep processing (processed.size() < n)

  • For each node in written set, get all the edges where this node is part of, and insert them into current_edges set.
  • For each edge in current_edges set, get both nodes (one of them is alredy processed at this point, but I was too lazy to do the additional if statement), and insert to current_edges set all the edges that are greater than cure. Then, delete all these edges from it's edges index. If the set is empty, then insert it to processed set, otherwise, it should be processed fully so insert it into written set instead.

Solution link: https://codeforces.com/contest/1831/submission/207672990

It's a pitty I didn't got AC in the contest. I had a bug with lower_bound(...).

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

    I had a similar solution, I maintained an adjacency list so didn't need to use lower bound(because if once a node is inserted into current_edges it is either going to be processes fully in this iteration itself or the next iteration)

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

Did I miss some O(n) solution for D div 2 / B div 1? I tried square root decomposition, but I either get TLE or MLE. If I save the pairs as map<ii, int> I get TLE (which is understandable, as it is O(nlog(n)sqrt(n)). If I save them as unordered_map<i64, int> (using some hashing of course) I get MLE.

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

Can't wait for rating update! :)

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

So happy to. Victory thank, you

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

Very good problems, well done guys!

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

    Thank you! Which one was your favourite?

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

      In div1E it was very fun to figure out the precise invariant for operations, very cool and novel (at least to me). Definitely a highlight.

      Div1D is nice, div1C is good, and div1F looks interesting too (I'll try to solve it later).

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

Thanks for the round, finally blue!

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

D is a great problem with stupid Memory limit

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

    I might be paranoic but I thought 1024MB is just a big spoiler. For me reading 1024MB in that problem just means "do some nsqrt memory dp".

    Setting $$$n \le 10^5$$$ to reduce memory also seemed to spoil a little, what setter does $$$n \le 10^5$$$ if not for $$$O(n \cdot \sqrt{n})$$$ or $$$O(n \cdot log^2)$$$ solutions? There was also a scam that worked quite well with this limit.

    I get we could set 1024MB limit to all problems, but I was unsure we wouldn't run into technical issues then.

    And the hld to reduce memory was posted not long ago so I thought most people knew about it...

    Nevertheless, I'm happy you enjoyed the idea of the problem.

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

This is one of the best rounds I've taken in a while, Tho Mle for Div2 D could've been less strict, Thanks!

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

ehhhhh

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

can anyone explain me about problem 2 in div 2

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

    You are given 2 arrays a and b of length n. You have to merge these two arrays into c of length 2*n such that c has maximum length sub-array of equal element.

    Suppose a={1,2,2,3} and b={2,2,1,1}. We can merge it like, c={1,2,2,2,2,3,1,1}.here c[2,4](1 indexed)sub-array contains equal element. So answer is 4. Note that, We can also merge it in different way. Just keep mind that the Order of elements of array a and b will not change.

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

Div2 b Taught me not to use arrays when you can use vectors,

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

include<bits/stdc++.h>

using namespace std;

define endl "\n"

define ll long long

define F first

define S second

define no cout<<"NO\n"

define yes cout<<"YES\n"

define tests int t; cin >> t; while (t--)

define sai ios_base::sync_with_stdio(0);cin.tie(0);

define upp(str) transform(str.begin(), str.end(), str.begin(), ::toupper);

define low(str) transform(str.begin(), str.end(), str.begin(), ::tolower);

typedef vectorvi; const ll mod = 1e9 + 7, mod2 = 998244353; bool ispow2(long long int i){return i&&(i&-i)==i;}

//___________________________________________________________________________________________// void solve() { int n; cin>>n;

vi a(n),b(n);
for(auto &i:a)cin>>i;
for(auto &i:b)cin>>i;

//for(auto i:a)cout<<i<<" ";cout<<endl;
unordered_map<int,int>aa;
unordered_map<int,int>bb;
for(int i=0;i<n;i++)
{
    int c=1;
    while(i<n and a[i]==a[i+1])
    {
       c++;
       i++;
    }


    if(aa.find(a[i])!=aa.end())
         aa[a[i]]=max(aa[a[i]],c);
       else
         aa.insert({a[i],c});

}
for(int i=0;i<n;i++)
{
    int c=1;
    while(i<n and b[i]==b[i+1])
    {
       c++;
       i++;
    }


    if(bb.find(b[i])!=bb.end())
         bb[b[i]]=max(bb[b[i]],c);
       else
         bb.insert({b[i],c});


}

int ans=0;
for(auto i:aa)
{
    int c=i.second;
    if(bb.find(i.first)==bb.end())
       ans=max(ans,c);
    else ans=max(ans,c+bb.at(i.first));
}
int ans1=0;
for(auto i:bb)
{
    int c=i.second;
    if(aa.find(i.first)==aa.end())
       ans1=max(ans1,c);
    else ans1=max(ans1,c+aa.at(i.first));
}
cout<<ans<<endl;

} int main() { sai tests { solve(); } }

can any one tell me where Iam making mistake div2 problem b

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

Would someone be able to check why my solution to Div 2 D TLEs on case 8?

It's basically the same as the official solution and runs in O(n*sqrt(n)), so I'm unsure why it TLEs.

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

Problems D seems like a typical atcoder ABC F