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

Автор IceKnight1093, 2 месяца назад, По-английски

We invite you to participate in CodeChef’s Starters 157, this Wednesday, 23th October, rated upto 5 stars (i.e. for users with rating < 2200).

Time: 8:00 PM — 10:00 PM IST

Joining us on the problem setting panel are:

Problem distribution:

  • Division $$$1$$$: $$$5$$$ problems
  • Division $$$2$$$: $$$6$$$ problems
  • Division $$$3$$$: $$$7$$$ problems, of which $$$1$$$ is a subtask
  • Division $$$4$$$: $$$8$$$ problems, of which $$$1$$$ is a subtask

Written editorials will be available for all on discuss.codechef.com. Pro users can find the editorials directly on the problem pages after the contest. The video editorials of the problems will be available only to Pro users.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here. Hope to see you participating.

Good luck!


Congrats to the top 5 in Div1!

  1. Egor
  2. maspy
  3. Kude
  4. liympanda
  5. noya2
  • Проголосовать: нравится
  • +55
  • Проголосовать: не нравится

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

Please mention the total number of problems division wise, like Dominater069 mentions in his blogs about codechef contest?

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

Reminder: Contest starts in 30 minutes

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

in normal is good. How to calculate the number of subarrays such that the frequency of 1 equals the frequency of 3 and there exists at least 2 in the subarray. I spent the entire contest trying to implement it but I wasn't able to.

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

    let $$$ai$$$ and $$$bi$$$ are cnt of 1 and 3 till index i respectively
    $$$ai - aj = bi - bj$$$
    $$$ai - bi = aj - bj$$$
    this trick is same as we use in two sum problem

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

    you can replace 1 -> -1 and 2 -> 0 and 3 -> 1,

    1. count the number of subarrays having sum zero,
    2. find the segments where there is no zero i.e the segments which contain only 1 and -1 and again calculate the number of subarrays with zero sum for these segments, and subtract this count from the total count.
    3. you also have to count the subarrays with only -1 and only 1 and add this count to the answer.
    
  • »
    »
    2 месяца назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

    You can make a queue, which holds all the prefixes in that dont have a 2 in front of them, and then empty the queue into a map each time you see a 2

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

Seriously I don 't see any reason why constraint on MEDIANT is so small like $$$N\le5000$$$ I mean seriously? There was clearly an easy $$$O(N)$$$ solution , I don't even know how a $$$O(N^2)$$$ solution would look like. Why such unnecessary small constraints??It nothing but created confusion

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

    I did it with an O(n^2) maybe he considered safeguarding idiots like me

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

    how would you check if solution is correct or not in $$$O(n)$$$.

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

      main observation is that if the minimum number is present after the last index of the maximum number then impossible

      if possible then no matter what subarrays you choose for operation you will find a sorted array in the end

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

        i know the solution
        i'm trying to say that constraints are lowered so that CHECKER can run in $$$O(N^2)$$$ or may be something better, but surely not in $$$O(n)$$$.

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

          oh yeah you also have a point , if checker can't check in $$$O(N)$$$ then constraints have to be lowered for sure but again then it questions the fact whether the problem should exist at the first place.Because if a contestant has a straight-forward solution for larger constraints but checker can't afford that then it's not a proper problem to appear.You may ask why?Because as a contestant , when he approaches a problem constraints mean something to him , he can't think from a problem setter's viewpoint that constraints might have been lowered because of not being able to make a checker

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

            as a problemsetter I am telling you none of your sentences make sense

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

            I saw a problem. Due to my own reasons, i assumed it was dp. I failed to solve it. The editorial was greedy.

            Such a bad problem smh. Why didn't problemsetter tell me it is solved with greedy?

            Whether you think this problem is fine or not is a separate issue, but your argument is completely invalid. Constraints exist not to tell you that do this in O(N) but to deny solutions that run in O(N^3) for example. It is not to mislead you to a solution, rather to not give hints. If you do try to infer stuff from constraints, do it at your own risk

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

      Edit: Sorry my approach had flaws, we can't keep doing both identification of median and modification of array in logarithmic time complexity.

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

        we can identify and remove any element in O(log(n)) as per given output from user

        how will you identify and remove median in range $$$L..R$$$.

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

          oh sorry!! Since after removing any element the array is getting modified, we can't (at my level, maybe someone can) keep doing both operations at logarithmic time complexity. If the array was constant we could have identified median using kind of merge sort tree. I'm really Sorry for wasting your time.

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

Video Editorial for A-D with detailed explanation

D WAS really an amazing Problem

Link : YOUTUBE LINK --Click here