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

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

Hello Codeforces!

We, the disciples of Omkar (qlf9, Tlatoani, MagentaCobra, golions, and Omkar's newest disciple, rabaiBomkarBittalBang), have written our third contest: Codeforces Round 724 (Div. 2)Omkar 3. It will be held on Jun/06/2021 17:35 (Moscow time) and will be rated for users in Division 2 (rating lower than 2100). As usual participants with rating >= 2100 are allowed to compete too, but the contest will be unrated for them.

You will be given 2 hours to solve 6 problems. There may or may not be an interactive problem, so it would behoove you to read the guide for interactive problems. There also may or may not be competitive programming problems, so you should be sure to thoroughly understand everything here.

We would like to thank:

The scoring distribution is 500 — 1000 — 1500 — 2000 — 2250 — 2500.

May Omkar be with you!

Update: Thank you for participating in our contest! The editorial is here. We have video editorials for every problem there!

Update:

The winners in official standings:

  1. xin_chen

  2. adc-s11-sadge

  3. conqueror_of_rainboy

  4. XOXOX

  5. TwTwTwTwT

The winners in unofficial standings:

  1. neal

  2. Maksim1744

  3. dlalswp25

  4. hank55663

  5. fanache99

Congrats!

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

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

As a tester, Omkar orz!

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

Hope you all enjoy our problems :)

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

As a tester, I must say problems are really interesting !! All the Best :)

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

Interesting problems.

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

everyone click the Omkar 3 link

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

I'm still thinking that you all guys know Hindi ?

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

Very quick scoring announcement!

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

Scoring looks pretty balanced, gonna be a nice round!!!

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

When i see there are a lot rounds comming in codeforces :

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

It's time that these posts should use the word "Bugaboo" instead of "problem".

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

I was hoping for becoming Expert but now I might get demoted to pupil :(

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

I like this scoring distribution

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

Wow , another contest this week. If codechef could conduct as many contest as they launch new courses for cp then I would have become 4 star on cc xDD.

»
3 года назад, # |
  Проголосовать: нравится +31 Проголосовать: не нравится
Problem / Bugaboo Names of this Contest
»
3 года назад, # |
  Проголосовать: нравится -38 Проголосовать: не нравится

Brother,just curious to know Omkar means what? The link you provided Omkar3 is youtube link that's the hinduism. From my perspective, Here all contestant are not hindu. But you are spreading your religion by Omkar?

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

    You can just replace omkar with god. This is maybe not for spreading any religion, but instead it creates a humour(here). Also the link is a part of that joke, pointing that its their third contest(its like they created a third part of a kids movie)

    At first it baffled me. But later I recognized that it lightened my mood.

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

    .

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

Why the organisers are obsessed with Omkar. I don't think they even know Hindi.

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

Hope so I will be able to solve B this time

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

Just curious how to become tester

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

    You should be personally familiar with some problem setter, so (s)he could personally kick the s**t out of you if you leak some problems beforehand, spoiling the contest and efforts of many people )

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

I love CF

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

I don't have much sense of humour, can someone explain what's going on?

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

The good' ol 6 problem 2 hr div2 is back finally!

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

"There also may or may not be competitive programming problems" yeah like why would you include competitive programming problems in a competitive programming contest, that would be very weird.

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

Scoring looks encouraging!

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

God for creating the world and the human race.

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

after looking at a few comments up here, I would like to imagine a Latin American guy named Jesus creating a round, then they put his name on all problems and thanked him in the announcement blog

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

    He wouldn't say that he created the world and human race, right?

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

      lol Everytime someone has prob with other religion,it is always muslim guy from Indian subcontinent,from santa time to omkar name ( although omkar is name of problem setter and he has surely written that in sarcastic way )and even if he hadn't why did you care so much,I know one muslim writer (Dont remember name) has written " all credits due to allah and allah has created world " thing but then no one felt offended lol and then he say " respect all religions"

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

        Should I reply your comment with a fake id?

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

          who say this id is fake?If it was fake I wouldnt have been active daily for the last 6-7 month,Its just that I prefer upsolving instead of giving contest btw You also know I spit a fact so you brought fake id thing in reply

          LET CF BE CODING COMMUNITY DONT MAKE IT SITE TO START WAR ON RELIGION BASIS OR NATIONALITY BASIS ALL CODERS ARE SAME

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

            Do you know about the new feature of codeforces that if you solve any problem it will be showed in your profile. And your profile says that you didn't solve a problem since April, and you total solved 8 problems since you created this fake account!

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

              Great job exposing your own fake account used for cheating in contests.

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

              Have you even heard of mashup thing,I had done lots of mashup but is this even a point? Point was that you guys had always problem whether it is santa or omkar (although not all muslims, Every community has black spot and I think you are that in Muslims ,cause none of muslims brothers commented except you)

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

      If you want to debate on religion. I'll happy to join you on Twitter. Please let this site be for CP only. It shouldn't matter to anyone if problem setters add one two lines for humour and thanking god according to their own faith.

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

.

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

Omkar orz... Om Namah Shivay!

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

Will Omkar inspire the authors to release the Editorial eventually?

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

there also may or may not be rated contest so you should read all of the rules about unrated contest.

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

ok

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

What is the Meaning of Omkar ?

The word OM came from Hindu mythology.

OMKAR ओंकार —

OM + KAR = Om is a indeclinable .It is a sacred syllable and is Uttered as a holy exclamation at the beginning and end of a reading of the Vedas or previous to the commencement of a prayer or sacred work.

KAR is from kri कृ root word , which means doing , making , performing.

It is a term, denoting a sound or word which is not inflected.

OMKAR is a SACRED syllable OM itself.

The exclamation OM. It is a Supreme Brahm.

OMKAR is a powerful word when chanting gives physical and mental health. One can feel certain vibrations in the body and so it controls anger, increases patience and tolerance levels.

Chanting of Omkar improves concentration, brings down stress, anxiety, and tension.

It is a meditation. It reduces negativity.

So the meaning of the name has powerful meanings.

I think this will help you.

Sources: What is the meaning of the name Onkar?, What is Meaning of Omkar

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

    Yes, True that. Only I would like to add-

    . "Om" is considered to be the cosmic sound. It originates back when nothing existed and space was empty & quiet, the creation of universe brought with itself the vibrations of Om. And hence it was the first sound that ever originated.

    . Proper chanting of "OM" has remedial effects on any mental or physical stress because "om" is considered to be made up of every possible frequencies of sound and when chanted, it tunes with the frequencies of self and provides relief.

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

golions, Is there any way to become disciple of Omkar?

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

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

Good Luck everyone!

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

Hail Omkar

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

When a problem score is 2000, does it mean its difficulty is 2000?

I am new to codeforces. Pardon me.

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

    No, it doesn't. The problem score means only the gap between difficulties of the problems. In average it's close to the truth, but now always :)

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

    No. It is the maximum score you can get upon solving the problem. Difficulty is assigned to a problem after the contest is over, on the basis of ratings of participants who were successfully able to solve it.

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

The Marking system feels shit, if you submit first in just 3 min with one error, gives less marks compared to someone who solved it after 25 minutes.

ughhhh

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

    Wrong submissions have penalties. You should consider checking on more test cases before submitting.

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

      Saying by not even sitting in the contest sounds good.

      Here I am the one who failed horribly in the contest and there you are who didn't attend a single contest giving and firing your utopian quotes on me. :)

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

        Sorry if that hurt you. I know how it feels dude. I already solved 3 problems with 5 wrong submissions, I already had negative contributions, so I was just afraid to comment with my actual id because of down votes. hehe, LOL!

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

          Hey bro finally, I submitted 3 with one wrong submission ;)

          when I was chatting with you at that time I was at one :)

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

I personally wouldn't be surprised if someone said: "Anton did NOT reject problems for this contest!"

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

Was Div2 A always this hard?

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

    nah, i consider this problem to be on div2 b/easy c level

    the fact that problem statement is written so bad makes this problem even harder

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

    It wasn't that hard especially if you look at the constraints, which made it quite easy to implement.

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

The problem statements should rather be considered as riddles.

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

i still don't have Diluc and Fischl..ehe..maybe that's why i still fail to solve their problems

»
3 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится
There also may or may not be competitive programming problems 

Very true, now my tongue has well-defined six-pack abs after going through these tongue twisters.

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

me on A: 31 minutes B: 28 C: 24 I'm not saying it's not balanced but WTF is wrong with me why do I start like an idiot then focus more and more

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

    supahotfire CM perf orz

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

    For me A was harder than B and C. Actually I am not sure if A works. I implemented some brute force for both, A and B, without being able to see if then will TLE or not.

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

      Edit: nvm it was bullshit

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

        if there is one negative number the difference will still be positive since we are taking absolute value

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

          If there's one negative number and a positive one then you will have to infinitely add new numbers

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

        Nope, why should it fail??

        If the array is [-a, 0]. Then their absolute diff is still positive (|a|). So it will go on forever. Don't give such heart attacks, I solved with the same logic as you lol.

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

Thanks problem B for negative Delta :)

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

First task was pretty hard for div.2 ( Thanks for your time spent for making a contest)

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

participating today was a bad idea

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

I see a huge gap between C and D, but on the other hand there where still a lot of people solving D.

Maybe I missed some more or less obvious observation.

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

    Yeah, you missed a small observation. Let's build array a based on array b from the beginning. So for every operation, we can add at most 2 elements into a. So for the current move, if the previous median is not equal to the new median then there cannot be an element in the array we build (a) whose value is in between the new median and the old median. Because if you add two unknown elements into array [1,2,3,4,5,6,7] then the median can be one of 3,4 and 5.

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

Can someone please help me where I went wrong for bugaboo C? I was getting correct answer on test cases and I am pretty sure about the logic too. 118652416

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

    Not sure how this is supposed to work dp[j] = max(dp[j], j / i);

    The ratio is arr[0][i]/arr[1][i], but not the mathmatical result of the division, but the fraction. So we need to divide both values by gcd(), and then count foreach position how much of them exist left of that position.

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

      If the ratio of D:K upto position j is equal to that upto position i, then I am updating dp[j] to be the number of conntinous groups of size i which is j/i.

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

Many E's will fail today (at least 2 in my room itself) because they will print $$$-1$$$ instead of $$$10^{9}+6$$$ but I was too lazy to hack lol.

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

Can't believe 3k people solved C

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

    It was easy. Just needed to notice then ratio of D/K remains same as the total. After that its just binary search.

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

      A safer approach than doubles is to store a pair <x, y> representing x / y. However be careful to store it in its reduced form, that is, where gcd(x, y) = 1.

      Also instead of binary search, we can just store the number of times we have encountered this reduced fraction when iterating from left to right.

      Implementation: 118610628

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

    Its a pretty common idea that has appeared a lot (especially at the start of this year on Codechef) — having a map storing some property which becomes the same (or similar) for all valid ranges then checking for each right end. So I don't think its that surprising that a lot of people solved it.

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

      Its a pretty common idea that has appeared a lot
      Can you please give one of those links?

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

        I'm not really good at remembering problem names, but two examples of problems using the right end of a subarray idea, that are somewhat similar to this problem are:

        Mex Subsequence

        Sed Passwords

        There were 2-3 others ones I think (including some at a comparable difficulty to this C that didn't need dp), but I only remember the names of these two problems since I was involved with testing them.

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

    C was easier than B. I think we have to just maintain the simplified ratio of D and K we got till now.

    Like 1:2 is same as 2:4 and which is same as 4:8 so, just divide D and K by gcd for that. As ratio of one part of the string must of equal to the ratio of complete prefix.

    But i feel B more harder than C. Although there was not much difference.

    BTW problem similar to B was also on HackerEarth Link

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

    I don't think that C was 3k easy. Something else is going on.

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

Hello,bro,may i ask how to solve Problem C ? Actually, i don't know the reason why i get wrong answer , :(

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

Out of curiosity, is there a way to solve D by sort of simulating the valid ranges $$$a_i$$$ could lie in using coordinate compression on $$$b_i$$$ plus something like a fenwick tree?

Something like when you initially place a new element we constrain it to lie between (-INF, $$$b_{i} - 1$$$] or [$$$b_{i} + 1$$$, INF), assume they initially lie at the left end and use a fenwick tree to count how many we can move to the right.

I know the intended solution using upper and lower value stacks is easier and more elegant but I'm just curious if such an approach is feasible.

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

    segment tree is very indian

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

    I thought of following approach but could not implement, could someone tell if how to implement if their solution was similar :

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

    Yes, that is more or less what I did. Compress coordinates. Use a binary indexed tree to keep track of values that are fixed. All values from the input need to be fixed, and if values are repeating, it is enough to fix each value once. Values that are not fixed are either minus or plus infinity, and we keep track of the counts. So, iterate over the input array. The first value goes to the Fenwick tree directly.After that, for each value, check how many values so far were strictly larger (including values from BIT and plus infinities), strictly smaller (including values from BIT and minus infinities) and equal to the new intended median. If the value of the median was not fixed before, fix it. The remaining values (1 or 2 depending on whether we had to fix a new value in this iteration) become minus or plus infinity, depending which category is less numerous. After the assignment, check if the supposed median is actually a median.

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

How to solve C ? I tried to iterate on divisors of count of 'D' and then finding the value for possible count for 'K' and then check if the ratio existed somewhere. But I kept wrong answer on Pretest2. my submission. What is the correct procedure to solve this sum ?

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

    Even I tried to do the same but got WA on Pretest 2. :(

    118652416

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

    The key observation is, that if we remove a prefix of given ratio, the remaining part has same ratio.

    So foreach position, we need to find the number of positions left of it with same ratio.

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

    Create a map<pair<int,int>,int> where the key is the ratio, seen as a pair of ints instead of a double. Iterate through the string and keep two counters, current numbers of D (currD) and current numbers of K (currK), for every position in the string call x=gcd(currD,currK) and add one to map[{currD/x,currK/x}] and thats the answer for that position. You are counting how many segments are with the same ratio than your current position.

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

    **if A/B = C/D = E/F then A/B = C/D = E/F = ... = (A+B+E+...)/(C+D+F...) ** Thus a prefix can be divided into Components if The count ratio of D and K in all the partitions is same as that of Prefix . How to Store Fraction in Their Simplest Form : simple form of x/y is X/Y = (x/G)/(y/G) where G=__gcd(x,y) . We Can use map to store the position of Last index where the ratio was {X,Y} if the ratio at any index is i {a,b} the ans[i] = 1 + ans[pos[{a,b}]]; pos is a map.

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

    Move along the array from left to right and for each prefix, find the ratio of D/K (rounded down to simplest form). Maintain a map to count the number of occurrences of this ratio and then the answer for index i is simply mp[ratio] + 1. It is always better to store the ratio as a pair of numerator and denominator to avoid division by 0.

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

    Suppose when iterating from left to right, at index $$$i$$$, we have $$$cnt_D$$$ occurances of $$$D$$$ and $$$cnt_k$$$ occurances of $$$K$$$.

    Now let us note that for a given string, if all the components have the same ratio $$$x:y$$$, then the total string will also have the ratio $$$x:y$$$. So it is sufficient to check for only this ratio.

    Now the answer is just many prefixes till index $$$i$$$ has a ratio $$$x:y$$$ occurred. This works as if for some $$$j \lt i$$$ $$$x_{j}:y_{j}$$$ and $$$x_{i}:y_{i}$$$ have the same ratio, then $$$x_{i}-x_{j}:y_{i}-y_{j}$$$ must have the same ratio. So we can just count this using a map of pairs $$$(x, y)$$$

    However we must also take care of the fact that $$$x:y$$$ and $$$kx:ky$$$ are the same ratio. To do so we can just reduce the ratio to its lowest form by dividing both terms by $$$gcd(numerator, denominator)$$$.

    Code: 118610628

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

Thank you for the contest!

I kinda feel like C and D should be swapped, but then again it's kind of my fault I didn't start reading D after getting stuck on C I guess.

Anyway, it's not really much of a problem, the bugaboos were IMHO still good!

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

Well, Problem E seemed really difficult at first. But the solution is merely two lines!

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

How to solve E ?

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

    I didn't submit since I was too late, but my solution got the samples correct.

    Spoiler

    UPD: Idea got AC post-contest

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

    So, basically, you fix each hash to be 0 or non-zero. Now, which elements in matrix are zero and which are non-zero. Now, suppose you fix the hash at position (i,j) in the matrix to be non-zero, then the value of (i,j) will be the manhattan distance to the nearest zero. My proof is quite tedious but try proving it by contradiction.

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

I just want to know , whether i will have any rating change , if i didn't submit a single line of code, no right no wrong??

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

too many redudant statement, can't understand problem C :(

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

segment tree is very indian

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

My submission to A is totally not legit (TLE), but I managed to pass system tests anyway. Here's my video of the round: https://www.youtube.com/watch?v=dXS6nNiYeZs

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

meet a new cheater This is how Master_Jiraya bypasses Plagiarism testing.

I am watching him from so many contest , He has done this today and in previous contest, and I am sure he must have done it multiple times before as well. People like Master_Jiraya are spoiling the sport. I don't understand where would cheating take them in life. They will never get anywhere in life but always remain what they are i.e cheater. He should be banned from the platform as soon as possible . MikeMirzayanov sir pls ban him and skip his solutions .

todays submission 118639631 118614794 saw his submission time , he is that much pro that he can solved problems in 2 minutes .

kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++;kedos++; jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++;jai++; jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;jai++;kedos++;jai++;jai--;kedos--;kedos++;kedos++;jai--;

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

How the hell was B approved?! Such an annoying to code problem. The average problem-A on CF requires more thinking than that. I liked C, A today and have almost no clue why my D or E passed. Seemingly dumb guesses that I can't prove.

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

Can anyone give some hints for D?

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

    Whenever you add the two new integers, you have three options.

    1. Add them to the left of the previous median. This results in shifting the median one to left.
    2. Add them to the right of the previous median. This results in shifting the median one to the right.
    3. Add one on either side. Same as previous median.

    Try to think of the situation where the answer would be "NO".

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

How can https://codeforces.com/contest/1536/submission/118604068 solution pass if the question doesn't say we can remove the element?

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

stories (short or big) in problems are good if they can somehow help in imagining. In A,B,C,D if problems were without stories then it would have been good.

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

In C I somehow thought I should split the prefix evenly which waste a lot of time of mine :(

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

Strong Pretests !! :|

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

My opinion about C:

WTF is this explanation ?!! if someone couldn't understand the explanation then he'll see the samples, that's what I did but the sample explain another problem !! I (and I think a lot of peoble) understood it like every segment should have the same number of 'K's and 'D's.

question for the authors: couldn't put a good sample to explain another cases ??!!

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

    Exactly, I also understood the problem to be this, and could not come up with why it is not passing for about 1 hour.. before realizing that the ratio are compared in simplest form.

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

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

Did anyone tried to solve C using sieve? My Attempt — 118650015

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

118650415 why TLE? Problem -: B

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

    Use m.find(g)==m.end() instead of $$$m[g]!=1$$$. This is the cause you are getting TLE. In map, [] operator store the key, then check value.

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

EBACDF

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

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

Random fact: B can be solved in $$$O(n*|\Sigma|)$$$ using dp on suffix automaton (code). This approach can solve the problem even if $$$n\leq 10^6$$$.

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

My code for B. It is most likely to get MLE in SysTests. Can somebody say, why the memory usage has skyrocketed?

UPD: It passed :'). Still, can somebody tell why the memory usage has skyrocketed? I have used simple brute force.

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

While I'm practicing problems with difficulty 2500, it's very sad that I couldn't solve even C. I didn't have a good observation to solve D either. Not sure what's wrong with me...

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

    you are me+(300-500) cf rating. i am solving so many 2000 problem and still took so much time to solve B, but solved C just by looking at it

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

Problem A and C are hard to implement :)

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

    turns out you can just print from 0 to 100 for A if there isn't a negative element in the array

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

118650415 why TLE? Problem -: B

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

    Although you know that it will run at most n time for any string (worst case: consecutive subsequences) but there's still some additional calculation in the loop so you need to break all the outer loop after you have found the answer.

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

      I just added a break after checking a single character if the ans is present and it gave accepted ... its worst complexity is still O(26*26*26) . How it is possible?

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

        unnecessary loops for each test case are huge when you don't break after you have found an optimal solution.

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

          And if there is a huge test case with answer of 3 characters then? will it no give tle? Btw thanks for helping

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

How to approach slightly modified problem C, if it is asked to find the number of ways to split such that the ratio (D/K) should be the same?

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

very nice problems! E was unfortunately very proof-by-AC-able, but the actual induction proof is super clever

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

Dang, I feel like an idiot. When solving A, I didn't realize that the version of Python 3 on the server only supports the 2-argument version of math.gcd(). It took me 17 minutes and 7 wrong submissions to debug this simple error.

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

    One more thing to add here. CF states that it is using CPython version 3.9.1, but if you run

    import sys
    print(sys.version)
    

    you can see that the actual version is 3.8.1. The updated feature to math.gcd you wanted to use was added in Python 3.9. So I'd argue CF is definitely at fault here by mislabeling its version.

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

Idea for E:

Fix which #s turn into 0s.

All other numbers are uniquely determined. Imagine a multisource BFS from every 0. The value of a certain cell is simply its distance to the closest 0.

Answer is 2^X, where X is the number of #s (Edge case if there are no 0s in the original matrix. Then the answer is 2^X-1).

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

    Can you explain to me how is the answer 2^x ? Test case like ##0 when doing 2^x that means at some time the test case will become 110 and it doesn't follow the second constraint of the problem, so how is it 2^x ?

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

      For your input the answer is 4, and 110 doesn't appear: 210, 010, 100, 000

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

I had written correct logic for Problem C during the contest but it was exceeding time limit just because standard print method of Java was not fast enough for the given constraints. Isn't it unfair for non-C++ coders !! The constraint of 2 * 10^5 is carefully chosen to avoid these language specific problems and is widely used. I wonder why it was not considered during the testing phase!! :( golions

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

    We have model solution in Java. In the future I recommend that you use StringJoiner or StringBuilder when outputting a lot of numbers.

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

how can the last output for this test

test

be 2 ? you cannot even divide a string of length 9 in 2 equal chunks .

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

    [KKKDDK] and [DKK] ratio is 1/2

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

    You don't have to equally divide the chunks.

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

      then why is it written this ? Both brothers act with dignity, so they want to split the wood as evenly as possible. as far as i understand english " Even distribution " means equal distribution of something . Thanks to the problem setters you guys have written some beautiful problem statemnts .

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

Problem E is virtually equivalent to 2013 USAJMO Problem 2: https://artofproblemsolving.com/community/c5h532231p3041818

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

To not keep you waiting, the ratings updated preliminarily. We will remove cheaters and update the ratings again soon!

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

I will be green again once cheaters are removed :) . Just 1 point away from being green again .

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

road to purple!!!

first milestone reached, feeling fucking A. Lets go !!!!

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

Isn't "aaa" lexicographically smaller than "ac" according to rule 2 from Problem B. Can anyone explain why this is not correct?

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

    It has more characters

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

    But it's longer than ac, in the problem it needs the shortest one.

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

    Because in statement it is said that: "The MEX of the string is defined as the SHORTEST string that doesn't appear as a contiguous substring in the input." So mex is string of length two, and if there are more than one string of length 2, that sutisfies the condition of mex, than you should pick the lexicographically smallest among those(of length 2).

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

    btw if it was based on lexicographically smallest, the answer would always be a prefix of the infinite string: aaaaaa.... lol

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

Can anyone tell what is the best method to generate strings like a,b,c.....z,aa,ab,ab.....az,ba,bb..... and so on in problem B and store in a vector? What is the easiest method? Please share your piece of code.

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

    wasn't able to solve this problem during the contest but after the contest I search for this and luckily found this beautiful way to generate all substring and solve this problem

    string MEX(string s,int n){

    vector<string>substrings;// will store all substring in sorted order
    substrings.push_back("");
    while(true){
        vector<string>temp;// stores all substrings generated in this iteration 
        for(auto c: substrings){// iterating over all subtring 
            for(char i='a';i<='z';i++){
                string str = c;
                str.push_back(i);// adding a,b,c one by one to generate new subtring
                temp.push_back(str);// pushing in temp to use it on next iteration
                if(s.find(str) == string::npos){
                    return str;
                }
            }
    
        }
        substrings.swap(temp);    
    }
    return "";

    }

    Example to understand clearly

    initially, substring contains an empty string we are adding a,b,c...z, one by one to "" and pushing back to temp so temp contains {a,b,c,d.....z} now swap temp and substring Now substring contain {a,b,c,.....z} here the magic happens Now you will extract a (first element) and again add a,b,c...z, one by one so the new substring becomes aa,ab,ac...az you will do the same thing for b,c,d....z so Now temp contains all subtring possible with two char

    Hope you understood it

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

    I use recursion: 118607108

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

Can anyone tell me the rating of each problem and the best time complexity to solve the problem New to CP, was able to solve only 1st problem also what kind of contest should I give as a beginner?

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

Спасибо!

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

Please check these two Submissions for Problem 'C' :-
1.) https://codeforces.com/contest/1536/submission/118643260
2.) https://codeforces.com/contest/1536/submission/118699081
Logic is same in both but in 1st submission, I used ratio (in double) as key and in 2nd, I used pair as key of unordered map.
1st one got accepted but 2nd one is giving TLE.
Please Check them ...

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

    Your calculation of hash of pair is poor. Do not combine hashes using simple xor as x ^ y. Use constructions like: x ^ (y + 0x9e3779b9 + (x << 6) + (x >> 2)) or x + y * 1000000007 (in this case you can use some prime number instead of 1000000007).

    And it pass testes: 118753875 and 118754141.

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

This contest's sytle is so strange than others.Almost every problem I had to find the law behind the title ,it's very easy if we find the law ,but if we cann't find the law ,it's very puzzling!...

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

Attention!

Your solution 118628482 for the problem 1536B significantly coincides with solutions Foundnt_Alice/118625677, Believeu_us/118628482. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

I have not cheated at all and two or more person can have same approach for the above problem as it was just about bruteforcing.Neither I have used any public code or ideone.com.You can also check my other codes.Please dont skip the solutions As it is a clear coincidence.MikeMirzayanov Please look into it.

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

Won't the cheaters be eliminated in this round ?