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

Автор CoderAnshu, 2 года назад, По-английски

Hi Codeforces!

I am pleased to invite you to Codeforces Round #793 (Div. 2), which will take place on 22.05.2022 17:35 (Московское время). You will be given 6 problems and 2 hours to solve them.

The round will be rated for participants of Division 2 with a rating lower than 2100. Division 1 participants can participate unofficially in the round.

All problems in this round were prepared by me and rivalq. We have worked on this round for a long time and hope you find every problem interesting.

I would like to thank:

Score Distribution:

750 – 1000 – 1500 – 2000 – 2500 – 2750

Good luck and have fun! See you in the standings. Make sure to read the statements very carefully.

Thanks to ak2006, video editorials for some of the problems will be available on his channel after the round.

Congratulations to winners!!

Global Top 5:

  1. jiangly, superfast AK!

  2. Beduardo

  3. SSRS_

  4. neal

  5. turmax

Official Top 5:

  1. Beduardo

  2. Brewess

  3. Kizuna_AI

  4. Focalors

  5. csyakuoi

Special mention to AwakeAnay for the only Indian to AK the round!

UPD 1: Links to video editorials of Problem B and Problem C

UPD 2: Editorial for problems A-D is here.

UPD 3: Editorial for E is added.

UPD 4: Editorial for F is added.

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

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

AmShZ orz, The captain of Iranian testers

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

CoderAnshu supremacy!

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

I downvoted you. Then, your contribution was raised by 1

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

Orz

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

As a true cyan (tester), I would recommend you to try the next problem if you get stuck ( '◡' )

Also, if you wouldn't mind
»
2 года назад, # |
  Проголосовать: нравится +32 Проголосовать: не нравится

As a tester, the problems are fairly interesting and quite challenging.

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

As a tester, I can confirm that the problems are high-quality and interesting, and cover a good range of topics, and would recommend participating in this contest.

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

I hope it will be great #793 div.2

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

CoderAnshu lord supremacy. :)

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

A contest by Indian Coder after such a long time!!! Very Excited!! Hoping that this contest turns out to be the best in recent times.

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

As a problem setter, I would really like all of you to participate.

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

i hope the round will be a bit better than previous

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

For the last two contests I have been fsting on problem D due to stupid implementation mistakes. Hopefully this contest I will be able to break the streak.(Hopefully by solving problem D )

Edit: Broke the streak by not solving D this time.:clownglasses:

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

Удачи и приятного время провождения! До встречи в турнирной таблице.

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

As a tester, I get to write a comment for some contribution. hue hue hue.

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

Notice in the last line

Make sure to read the statements very carefully.

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

All the best Everyone !

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

Hopefully the "best of 2022" which were replaced in the previous round will be seen here.

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

I hope I solve about 3 problems and become a specialist !!

Good luck for all participant!

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

All the best for all participants

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

As not a tester,give me contribution!

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

No offense though

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

Everything is so sorted, just look at the testers list! Efforts put everywhere.

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

Much Awaited Contest

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

I will be taking part in this contest.. I am getting back after nearly 1 year.. wish me good luck bois!!

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

Btw, 793 is a semiprime number. Hope that means at least half of problems will be great!

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

Good luck!

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

Best of luck to everyone!!

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

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

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

I believe in CoderAnshu & rivalq supremacy!

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

SwapOnPermutationForces.

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

Yet another unbalanced round... #SpeedForcesOP

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

Now I can finally sit and watch my rank fall due to so many wrong submissions.

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

Problems are tricy ig.

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

Would anyone please explain why the output of problem C is 7 for this input?

1

13

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

Thanks.

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

    Put 1 in the middle.

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

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

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

    Array: 10 9 8 7 1 5 3 6 2 7 8 9 10

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

    In reverse: 10 9 8 7 2 6 3 5 1 7 8 9 10

    My Approach if u want to know
»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

FML, I think I have the solution for E. Rip. I think it involves traversing each tree in the forest and doing a tree DP.

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

Guys!! Hope you liked the round. Please share your feedback on every problem. I will be really thankful.

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

    Because i solved till C, it was very great round!)

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

    unbalanced and stupid problems

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

      Not fair. Frankly speaking, it happens not so often, but A was pretty. As for B, i am not a pro of bitwise operations, but even i didn't found this one too hard. And C... some stupid mistakes, but after about 30 min i did found the right solution by painting samples into notepad, so i do not think that this round was disbalanced

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

    I was able to solve till $$$C$$$, and it felt okay, I had almost got $$$D$$$, it was a nice constructive problem, and I don't know why I was getting WA on test 2.

    It would be really helpful if anyone can explain what does this means ? I got this on $$$D$$$

    My submission: https://codeforces.cc/contest/1682/submission/158075759

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

      I guess there is a problem in amount of your edges, the compiler is trying to say you have to print another edge, but your code started to answer on the next test case, so you probably don't have enough edges printed. Sorry if I'm wrong

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

        Yeah, you were right, thanks for your help, I got one test case failing "100100100100", and now it got accepted :)

        It's a very sad thing that I wasn't able to find this basic test case during the contest..

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

    strong pretests for most of the problems and very clarifying statements .thanks for the round.

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

    Questions are very interesting. From B to D all of them involved a decent amount of thinking. Loved the round.

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

    I got TLE for using unordered_map instead of map in C... Bad contest :(

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

    sorry @CoderAnshu, I was upvoting but my mouse sucks, I accidentally clicked on downvote, I am sorry for it. hope you don't mind it

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

LinearForces :-)

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

C felt kinda tricky.

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

Why does the number of solvers of problem C go so high?

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

I can solve D quickly, but I can't handle A,B,C.It's weird.

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

    how to solve D?

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

    god damn stupid greedy thought always messes up my first three problems. Well it sometimes works, but the moments it doesn't work really affect my mind.

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

amazing samples guys

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

What's the solution to D?

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

    I create egdes as a circle, find a edge to remove, then for each two node (x, y) I need to change the degree, I remove the edge of (y, y + 1) and add the edge (x, y + 1) 158057894

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

      amazing simple solution! I have done a garbage code, by using link list and removing subgraphs of size 3 from boundary. In the end size 3 or 4 graph remains which is handled separately.

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

    If number of $$$1$$$'s is odd or there are no $$$1$$$'s at all the answer is "no", because the sum of degrees should be even (each edge is considered in $$$2$$$ degrees) and we should have at least $$$2$$$ leaves.

    To construct a solution, if the string is all $$$1$$$'s, just choose anyone of them to be the root and connect it to all the other nodes.

    Otherwise, connect each $$$0$$$ to the node before it ($$$0$$$ at node $$$1$$$ is connected to node $$$n$$$). Now we have chains starting with $$$1$$$ and ending with $$$0$$$ (call such endpoints "tails"). To make all the nodes in these chains valid, we have to connect odd number of edges to the tails.

    To do so, if all the $$$1$$$'s are consumed in the chains, just connect the tail of any chain to the tails of all the other chains. Otherwise, choose any unconsumed $$$1$$$ and connect it to all the chain tails and to any other unconsumed $$$1$$$.

    Such construction guarantees that no intersections occur, as we first add some edges between adjacent nodes (can't be intersected) and at the end we choose only one node and connect it to some other nodes.

    Submission

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

can anyone explain that how to solce c :*

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

    I just binary searched the answer. You can in linear time check whether an answer X is possible. Although I have to say it was tricky to implement, two WA submissions and like 30 minutes debugging for edge cases

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

    All numbers that appeared two or more times can appear in LIS of both original and reversed array. Then we distribute all numbers that appeared only once evenly in LIS of original array and reversed array. Note that we can share one number in both LISs, so the answer is x + (y + 1) / 2 where x is the number of numbers that appeared two or more times, and y is number of numbers that appeared once.

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

    I just count how many number appears 2 times or more as m2, 1 time as m1 and the answer is m2 + (m1 + 1) / 2.

    Example: 2 2 3 4 5 6 6 -> 2 3 6 5 6 4 2

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

Spent near one hour on E and then realized I made the wrong observation. I think A-E are all great problems.

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

Those who solved problem C with unordered_map, depending on the compiler version, fall on test 26 or 28. Test 28 is a my hack test :)

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

I think Problem B was slightly confusing in my opinion.I am not able to understand B problem clearly.

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

how to solve E?

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

    Build a graph with $$$(x_i, y_i)$$$ as edges. For each i, find path from $$$i$$$ to $$$a_i$$$. A pair $$$(x, y)$$$ can be swapped if the edge $$$(x, y)$$$ is the end of two paths. Edit: add code 158085317

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

      By "...the end pf two paths" do you mean the path where all of it's subtree nodes are located in their correct position?

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

        Sorry I don't get what you mean but I just realized that it may be beneficial to name an edge with its index rather than its two end points since vertices are moving. Let's say the path from $$$i$$$ to $$$a_i$$$ consists of edge $$$e_{b_1}, e_{b_2}, \dots, e_{b_n}$$$, and path from $$$j$$$ to $$$a_j$$$ consists of edge $$$e_{c_1}, e_{c_2}, \dots, e_{c_m}$$$. If $$$e_{b_n} = e_{c_m}$$$, we can swap that edge. Then remove that edge from the end of two two paths and look for another edge that is the end of some two paths.

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

Great round! Especially enjoyed E and F.

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

i literally did c in 8 minutes by using same approach as in editorial but was not confident enough and waited for it to fail main tests. but it passed :) edit: people made it hard just because it is problem "C". conclusion: don't judge a book by its cover

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

    that's so true, i suppose C can be easier than B for those who have no idea what bitwise is

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

Great problems, although didn’t solve E.

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

Why unordered map gives tle on codeforces?

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

is CF getting harder or people are getting so much better? Feels like an 1800 rate problem a few months ago would be just 1600 now. So many solved C

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

bullshit pretest for C

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

    Why would you use an unordered map when it is quite easy to exploit the hash collisions for it lol

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

    Congratulations!! You've reached the time which every coder reaches where he switches from hash map to map

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

Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!

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

Here is some feedback, loved the round overall! I think BCD in particular are excellent.

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

158034396

why TLE?

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

Nice round, loved the problems.

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

    I think in the past several months, they have found a way to trick the CF cheat detectors. That's why there are so many ACs for easy to medium problems now.

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

such a poor round wasted 2 hours

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

A should have been little easier :( I wasted more than 20 mins thinking there should be easier solution for A by having right one in my mind. Lesson learnt: Solve what comes to your mind first for A atleast

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

In 3rd Problem, If the array a = [1,2,2] , Then according to codeforces, correct answer is 2. Can anyone explain how is it possible. My Claim : Answer should be 1 and not 2 since it is asked "strictly increasing".

Thanks in Advance !!!

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

I don´t understand the problem B, why is {0,2,1} = 0?

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

Thanks for super fast editorial.

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

Good Round, I loved thinking about problem C, it was simple but tricky. going to remember it always. A great Round from an Indian problem setter.

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

for problem :c

test case :
5
1 1 2 3 3

the given answer is 3,could some one please explain how it can be 3.

i am getting answer as 2

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

I have some doubt in problem C.

For this test case

14

150482826 299981842 846268930 299981842 16711396 299981842 160038184 87399809 36731648 410799926 150482826 16711396 410799926 355178268

answer is 7, but my solution is outputting 6, may I know the problem here?

(My approach is to build a sequence greedily by sorting the array and then taking minimum of them and then placing rest of the numbers on left and right of that minimum found (leftMost after sorting) (Counting them just), so that I get a strictly increasing sequence even if reverse, numbers that come twice are put in either of the sides.)

Then I output the final answer as min(leftSum, rightSum) + 1

I am counting these leftSum and rightSum in the above approach.

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

    You are almost correct, but instead of always taking the minimum as the one being used by both the "leftSum" and the "rightSum", you can choose any of the number to be shared by both sequence. An example of this is "5 3 4 5 3" where both the left sequence and the right sequence used "4" in the LIS. Hope this helps :)

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

Thanks for this wonderful round!

I am finally a CM.

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

in problem B, with the input:

1

8

0 1 2 7 4 5 3 6

it seems like the answer is not correct, if im wrong, pls point out my mistakes.

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

    in problem statement it is clearly mentioned that value of X will always exist so this kind of test case not possible.

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

It's Indian territory. love IIT CoderAnshu

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

In problem D:

for input of: 1 4 1100

my submission: [submission:https://codeforces.com/contest/1682/submission/158117585] gives output of: YES 3 4 1 3 2 4 but the accepted answer is: YES 2 3 3 4 4 1

but I think my printed solution should also get accepted.. can someone please help me with this one. Thanks in Adv!!

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

Please help me

My solution for problem E got RTE in test 8, but I don't know why; please tell me why

Thank you!

My submission: https://codeforces.com/contest/1682/submission/158149795