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

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

Hello, Codeforces!

I am happy to invite you to Codeforces Round 771 (Div. 2), which will take place on Feb/14/2022 17:35 (Moscow time). The round will be rated for participants with rating lower than 2100. You will have 2 hours to solve 6 problems. The problems were authored and prepared by me.

I would like to thank the following people who made the round possible:

I hope you have no plans for Valentine's Day find the problems interesting and enjoy the round. See you in the standings! ❤

Scoring distribution: $$$500-750-1250-1750-2500-3250$$$

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

UPD: Editorial is out!

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

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

I hope you have no plans for Valentine's Day

are you cursing us

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

Sorry but I have plans for Valentine's Day — participating in your round! ❤

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

Do Programmers celebrate valentine's day? :)

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

Looks like the Codeforces Round 771 will be my Valentine this time:)

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

As a tester, good luck and enjoy problems!

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

    My plans for valentines day were to take this contest.

    Now that I got the notification that I tested it, I no longer have plans :(

    Good luck and have fun to the rest of you.

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

I hope you have no plans for Valentine's Day .

Now Codeforces is also playing with my emotions :(

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

sorry losers, I have plans for Valentine's Day :>>

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

Wait, What's Valentine's Day?

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

Expert (my ex) ,i hereby propose you to be mine again .❤

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

    Hopefully ,i won't FST on some problem and regain my love (expert) back. Probably a happy valentines for me.

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

Sorry but I have plans for Valentine's Day

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

Valentine's day is for Div 1 only.

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

No Valentine's day -- lets write codeforces contest!

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

Codeforces Single's Round.

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

This contest may be easy than previous contest

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

She left me because I'm still newbie. :))

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

PinkieRabbit pls stop participate div.2 round to enjoy Valentine's Day with me because it's unrated for you but I'm important for you!

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

Hopefully, I can get back to specialist :)

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

Will it contain any interactive problem?

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

Goodluck at Valentine's Round #1

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

I hope I won't need my registration for this round and will enjoy the date with my gf...

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

I rather prefer cf rounds than a piece of chocolate! This round's a such nice present for me

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

I'm having a plan on Valentine and will also participate in the round.

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

Petition to rename contest to:- Singles Counting contest for cf

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

This round is like my Valentine's Day now see my Valentine goes good or bad

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

I have plans, it's my birthday!!

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

I have no plans for Valentine's Day hope problems are interesting! ^_*

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

Will AI participate in this round?I guess AI dose not have a girlfriend.

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

    Considering that AlphaCode is pre-trained on natural language processing models, I guess we could find a way to ask AlphaCode whether they have a girlfriend and it's likely their answer would be true :|

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

      Maybe he will be hanging out with google assistant on the google cloud :)

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

On February 14, 1946, the world's first general-purpose computer was born at the University of Pennsylvania in the U.S. Please spend more time with your computer on this special holiday!

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

As previous contests shows: [](https://codeforces.com/blog/entry/57721) [](https://codeforces.com/blog/entry/50404) [](https://codeforces.com/blog/entry/23515) [](https://codeforces.com/blog/entry/6677) Programmers usually don't remember the festival unless the announcement notices it...

So plz don't mention it next time(

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

Happy Valentine's Contest Day !

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

Yeah yeah you are right. I dont have any plan tonight except for the contest because no girls will like an anime-fan boy. : (

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

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

    thx, am on the cliff of leaving problem solving, but i will keep going forward now

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

    When your kid from the future comes back in time and threatens you to work hard, so that he can have a better life.

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

AIs have plans for Valentine's Day, so they won't participate in this round

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

In fact, my girlfriend's name is codeforces.

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

Let's see if Valentine brings some good fortune for us.

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

Thanks for arranging the contest on valentine's day. Single me at least find something to have some fun and make my day memorable.

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

Recently i came across the problem "Long Comparison" . Since i am new to competitive programming , i am solving more new questions to build my problem solving ability . Now when i submitted solution to this problem with my own approach , it gave "Run Time Error" with "Exit Code 3" . Can anybody tell me what is going wrong with the approach which i have submitted .

Problem : 1613A - Long Comparison My Submission : 146344211

Please give your precious advice .

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

    Hi, next time you can check the editorial of the contest, there is a tutorial button in the downright of problem page.

    About your submission, since $$$p$$$ can be really large, you cannot represent two numbers with type int (int only has $$$\le$$$ 10 digits).

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

POV — You have solved A B C and you are randomly roaming in the site and waiting for the contest to end.

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

Wtf problem E is not about segment tree(((

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

Is D long implementation or i am wrong :/

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

    Not particularly. I wrote a relatively lengthy bfs idea and even then its below 100 lines incl template.

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

    Came up with a solution literally 1 min after the contest ended. Now have to wait till system testing to see if it works lol.

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

Unfortunately, I found a hackable submission 146415862 of krishnagskr983 but when I clicked on the Hack button, the web started to load and never charged, so I couldn't hack it. I had 10 minutes before the contest ends, the time when I discovered the submission. I have sent the code before the contest ends to one clarification, proof that I could submit the hack. What can we do now? atodo MikeMirzayanov

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

    And another thing, a lot of times, when I open a link with ctrl+click for example, the page doesn't charge and stays white forever (ends to reloading). Anyone is experiencing the same?

    I'm experiencing the same:

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

How to solve C?

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

    Hint — if there is any $$$i \lt j$$$ such that $$$p_i \gt p_j$$$, $$$p_j$$$ will be part of some previously created component.

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

Hint for E?

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

Is there any solution faster than $$$O((N+Q) \log (N+Q))$$$ in E?

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

    I guess no. But seems you need to be careful with your constant. I had to optimize a lot and use fast input methods to squeeze my segment tree solution through.

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

My comments for each problem:

A. Not bad, but quite implementation-based problem. Unfortunately, I got FST. XD

B. Fine. It seems there are some hack on this problem.

C. Today I became second-solver of C. Yay!

D. Quite interesting.

E. How to solve it?

F. Read, but didn't thought deeply about it.

Also, I think the gap between C-D-E is a bit large.

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

    E: maintain the set intervals of contiguous same colored indices. When you are about to color a sub-array [l, r]:

    1. two intervals (one on left side and one on right side of the sub-array) each might get broken into two intervals
    2. intervals which are strictly inside the sub-array from our set will be gone
    3. one interval indicating the sub-array will be added to the set

    Suppose we have a BIT built on the values of the array. Whenever we "touch" an interval [L, R] of current color C in step 1 or 2, we will make sure this interval's values are up to date. Suppose, X = the sum of all updates happened to C after the last update on this interval. Then, we will add X to L and -X to R+1 on our BIT. So, basically we are keeping only the intervals which we are accessing up to date.

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

Took me like 30 min to solve C, but couldn't solve B. :(

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

    Frankly, I feel the idea used in B is very standard. I've heard $$$n + 1$$$ "is it sortable" problems that use this trick. If you don't know it, its probably tougher to think of.

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

what are the hacks for problem B.

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

    Ig many solutions are gonna give TLE, because some peeps have manually swapped each element of the array, with a time complexity of O(N^2)

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

solved c, connected component will always be a subsegment. not sure if it's totally correct.

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

When processing operations in backwards order in D, how to avoid bfs / dfs? I see some participants have solved it with simple loops and I don't get how there is a guaranteed order with that.

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

How to solve D ? I noticed that for correct painting there must be consecutive 2 equal elements in every row & column. So I built a graph such that if consecutive element is to the right, I add edge to the (j+1)th element else to the (j-1)th element. Similarly for column. Then do topological sort. I also kept two arrays right and down stating if for the particular cell, the consecutive element for the row is to the right & for column to the down. And if not right, then while printing i will reduce the column number & similarly if not down, i will reduce row number. But this doesn't work. Could you help me where I got wrong ?

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

    My idea was a BFS backwards through the painting operations. Starting at the end, your 'next' (previous) operation must be a 2 by 2 square either of equal numbers, or of equal numbers which are unpainted (and any already painted numbers, since these are fixed now). Start with all the 'good' squares in a BFS queue, paint them, then paint any 'nearby' 2 by 2 squares which are now fine to be painted, and so on.

    If you reach the end of the queue and there are cells as yet not fixed, it's impossible. Otherwise print the operations back to front.

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

    lets say you have a $$$2 \times 2$$$ square of following configuration somewhere in your canvas...

     1 2
     3 3
    

    lets say your code pointed both cells to $$$(1,1) \to (2,1)$$$ and $$$(1,2) \to (2,2)$$$.

    but i guess in reality it should have been $$$(1,1) \to (1,2)$$$ and $$$(1,2) \to (2,2)$$$ or something but not the first case.

    how do you deal with such cases ?

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

    I was thinking along these lines for some time, I suspect very complex cases can occur for single cells or L shapes areas.

    As for the actual solution:

    • Suppose we're processing operations in backward order.

    • Lets call a "fixable" cell one that is coloured by a later operation.

    • We can colour a square without affecting later operation if all non-fixable cells in it are of the same colour.

    • It never makes sense to colour the same square twice since the later operation on the square will make the earlier one irrelevant.

    • Colouring a square can make at most the $$$9$$$ squares adjacent to it colourable now when they weren't before, so we can use a bfs to do this in $$$O(n ^ 2)$$$.

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

F is actually a nice problem, thanks! E is not bad too.

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

Quick idea of Problem D, but bad and buggy long code implementation due to my debugging ability

(UPD: The bottleneck is that I used scanf & printf instead of cin & cout with ios::tied which gets AC after the contest, that's really a lesson when I met the scale of input or output more than $$$1e6$$$.

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

Although I liked most problems Problem C was very very similar to this. I just copy pasted my code with one line modification. https://www.codechef.com/COOK137A/problems/ERASE/

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

I think it's insane to get TLE like that on problem B just because I am using python

146366116

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

the pretest cases for problem 2 are not at all good they can be a lot better-got tle while system testing if it would be during the contest, at least I would have tried fixing that at the time of the contest

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

Did someone leak a hackeable solution on B?

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

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

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

very disappointed by the problemset... Problem C was easier than B... Took me 15 min to solve C but even after hours can't figure out B... Setters should verify the difficulty level of any problem before rendering it....

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

    Problemset was godlike, only problem that wasn't that good was D, because it was heavy implementation based.

    But other problems? Really nice.

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

problem B...

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

146420483 Can someone please help me figure out why am i getting tle

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

Can anyone please tell me why my solution 146399384 takes so much memory, while similar implementations have very less memory. According to me, total array and vectors size included will be at max $$$2*n*m$$$ integers,which should not consume so much memory (242 MB).

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

Bad pretest (:

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

    You failing systests doesn't mean pretests are bad

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

      But they are bad. Quadratic solutions were passing on B, while the case (n, n-1, n-2,....), that have quadratic edges, was not on the pretests of C.

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

    Your code used a lot of memory indeed ! Pretest were fine . You are the first one i heard saying pretest are bad on problem C though . Yeah for B they allowed O(N^2) which later got fst

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

I guess pretests for problem B aren't that strong, for there is few test case containing duplicate.(Especially for sort based algorithms)

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

Actually I'd rather celebrate ENIAC Day than celebrate Valentine's Day as a competitive programmer.

P.S. though ENIAC Day is celebrated on Feb.15, ENIAC was announced to the public on exactly Feb.14, 1946.

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

Can anyone tell me how to optimise this one to avoid TLE I tried using DSU and to avoid O(n^2) complexities thought of a[I]>I and parent[I] is not =-1 i.r it isn't yet included in any of the connected components https://codeforces.com/contest/1638/submission/146477193

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

If we tweak problem A as : Given array is not always a permutation. I was wondering if is there any better ideas then N^2.

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

can someone explain to me how (https://codeforces.com/contest/1638/submission/146492255) these types of implementation for problem B works?

Sorry complete beginner here

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

    a way to solve problem B is to check whether the odd number sequence appeared in the origin array is non-decreasing, also the even number sequence.

    so lst[0] means the last number appeared in the even number sequence, as lst[1] means the odd number sequence.

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

    When you see a "x&1" operation you can see it as the same as "x%2". While bitwise AND operator (&) and MODULO (%) is a very different concepts, both expression above produces the same result

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

      Yep. People should just write x%2, the modern compilers don't need that extra hint. They can figure out using bitwise operator themselves.

      But sometimes we are just too used to the arcane versions.

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

I hope you have no plans for Valentine's Day

In fact, I did have plans: participating in another CP contest which overlapped with this one

... Why does everyone hold competitions on the same day ;-;