yash_daga's blog

By yash_daga, history, 11 months ago, In English

We invite you to participate in CodeChef’s Starters 95, this Wednesday, 21st June, rated till 6-stars Coders (ie. for users with rating < 2500).

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

Note that the duration is 2 hours. Read about the recent CodeChef changes here.

Joining us on the problem setting panel are:

Note: Some problems have subtasks

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 for all users for 1 day as soon as the contest ends, after which they 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!

  • Vote: I like it
  • +63
  • Vote: I do not like it

»
11 months ago, # |
Rev. 2   Vote: I like it +18 Vote: I do not like it

There is a typing mistake in the post. The date should be 21st June

»
11 months ago, # |
  Vote: I like it +7 Vote: I do not like it

yash_daga sir orz !..

»
11 months ago, # |
  Vote: I like it +3 Vote: I do not like it

AST_TheCoder kopsss bro

»
11 months ago, # |
  Vote: I like it +18 Vote: I do not like it
Wednesday
»
11 months ago, # |
  Vote: I like it +11 Vote: I do not like it

Contest starts in 30 minutes!

»
11 months ago, # |
  Vote: I like it +18 Vote: I do not like it

There is a mistake in Transfusion Chain problem.
Blood type O donors can also donate to recipients with blood types O, according to the test cases, but it is not mentioned in the statement.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    got two penalities due to this mistake if o is only for a,b,ab then i can use o only once at the start i think if in a running contest if some issue occurs due problem setters then all the penalties should not be counted on those problems

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it +13 Vote: I do not like it

      I don't think you get penalties in Starters anyway.

      • »
        »
        »
        »
        11 months ago, # ^ |
        Rev. 9   Vote: I like it -8 Vote: I do not like it
        • Mistake 1: Transfusion Chain Quesion, Don't we get penalties on submission time, as this announcement pop up after 1 Hour of completion of Contest, and Don't it disturbs your mind set of giving the Contest, as I am thinking for mistake in my logic in first question, for more than 20 minutes just because of their rubbish mistake, and the interesting part was that I was shocked to see more than 2000+ Accepted Submissions on that Problem in Div 2.
        • Mistake 2: In Partition and Maximize Question, the Equation firstly was max(l[i], l[i+1], l[i+2], ..., r[i]) till more than 1 Hour of the Contest, and after 1 Hour of the Contest, without any Announcement it get's written as max(l[i], l[i]+1, l[i]+2, ..., r[i]), Am I wrong Problem Setter's and Tester's yash_daga wuhudsm ?
        • Isn't this Contest was tested before announcement, If it is tested, then what were the tester's doing ?
        • Also almost all the three below Question's were on Expected Value, This is not definition of Balanced Contest BTW...
        • Updated:- I am sorry, from my point of view, I think the Contest was very Good overall, Some fault's can happen as we all are Human, But I can say the Problem's were very Interesting to upsolve...

        • »
          »
          »
          »
          »
          11 months ago, # ^ |
            Vote: I like it +27 Vote: I do not like it
          • We're sorry about this, but the statement was rectified within 10 minutes and a announcement along with pop-up was made at 20:17
          • This is a small latex error which I don't think affected anyone, it's obvious from the partitions mentioned in the statement what the author wants to convey.
          • I feel Break Array is more of a dp problem along with prefix sum optimisation, than a probability problem.
        • »
          »
          »
          »
          »
          11 months ago, # ^ |
            Vote: I like it +22 Vote: I do not like it

          who reads the entire easy problem in contests . people probably went with the flow in transfusion chain

»
11 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In the second testcase of ARRAY_BREAK, if the arr is [1], then after applying any operation will it include the expected sum?

Like it will be (sum+1)/(cnt+1) or sum/cnt(unaffected by this)?

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can someone please explain the second testcase? or the authors, just include how the ans came

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    If at any point the size of the array becomes one, then for all further operations, it will remain unchanged.

»
11 months ago, # |
  Vote: I like it +7 Vote: I do not like it

name it a probability(math) contest rather than a dsa or cp contest

»
11 months ago, # |
  Vote: I like it +10 Vote: I do not like it

MathChef :/

»
11 months ago, # |
  Vote: I like it +3 Vote: I do not like it

My O(K*N^2) submission is getting TLE on problem "Break this array".Runtime is too strict.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think you are doing lots of power operation

  • »
    »
    11 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Does your solution has an extra factor of log(MOD) due to modular division?

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      This is the submission -Link.It doesn't have extra log factor.

      • »
        »
        »
        »
        11 months ago, # ^ |
        Rev. 2   Vote: I like it +9 Vote: I do not like it

        when you have too many modulo operations it is better to store the modulo in a const variable, doing this makes your solution run in 0.7s

»
11 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

3 probability problem in a contest.. wth admin (:
also rating system skip the last contest rating which show on right side of problemset page, plz look at that.

»
11 months ago, # |
  Vote: I like it +7 Vote: I do not like it

How were people able to solve TRANCHAIN without even considering "blood group O can donate to O as well"?

I wasted the first 30 minutes on the first problem due to this typo.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    Ig many had studied biology in their lower grades . They went with the fact.

  • »
    »
    11 months ago, # ^ |
    Rev. 3   Vote: I like it -6 Vote: I do not like it

    Yeah same

  • »
    »
    11 months ago, # ^ |
      Vote: I like it -12 Vote: I do not like it

    It was really amazing and also simple.

      int n; cin>>n;
      unordered_map<string,int> mp;
      for(int i=0;i<n;i++){
      	string str; cin>>str; mp[str]++;
      }
      int mini = min(mp["A"],mp["B"]);
      cout<<n-mini<<endl;
    
»
11 months ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

Constraints of Guess game say that N >= 2 but for the first subtask it is N >= 1. How do you define the expectation when N == 1?

Unfortunately I just wrote my full solution to that but can't submit. Please allow practice mode.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    I think Kira_1234 got 60 points due to this. His full solution does not pass the first subtask because it has a testcase with N == 1

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it +23 Vote: I do not like it

      Thanks a lot for pointing this error out. I did not notice this and was wondering for the last hour what the issue in my code was.

  • »
    »
    11 months ago, # ^ |
      Vote: I like it +25 Vote: I do not like it

    Hey, sorry about this, the solutions have been rejudged after removing the n==1 case. 2 submissions were affected due to this.

»
11 months ago, # |
  Vote: I like it +24 Vote: I do not like it

i was getting 31/7 for the second sample test case in the problem break this array which equals 428571436 modulo 1e9+7. Can explain me what is the actual ans to it ?

  • »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it +12 Vote: I do not like it

    It is 41/12, the resulting arrays you get are not equiprobable, you can make a probability tree and get this result.

    Spoiler
    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      I see now, actually the probabilities were not completely independent for each stage, it had to be cumulated. The problem statement was a little unclear about this fact, i just assumed the process to be independent at each stage from the previous stages.

      Thanks for the clarification.

»
11 months ago, # |
  Vote: I like it +23 Vote: I do not like it

Thanks for the Contest. Though it was a bit math-heavy, I learned something new today.

»
11 months ago, # |
  Vote: I like it +13 Vote: I do not like it

Probability — GCD combination question was really very good.

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Alt-Tab question was good

»
11 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Can anyone explain me 2nd test case of ARRAY_BREAK?

  • »
    »
    11 months ago, # ^ |
    Rev. 2   Vote: I like it +41 Vote: I do not like it

    Since lots of people have trouble in understanding this, here's a probability tree explaining it.

    Spoiler
    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      i was able to get the total sum and number of possible partitions possible using dp with an algorithm of o(n^3*k) and seeing the explanation of the first test case, i thought maybe it's just the modular division of both but it was certainly a lot more than that, anyways it was my first time experiencing expected values problems.

    • »
      »
      »
      11 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can u plz tell me y didn't u take [1 2 3 4] when i is 4 and when i=5 [1 2 3 4 5] as u did when i=1 ,[1] and when i=2,[1 2]? can u plz explain what's happening here

»
11 months ago, # |
Rev. 2   Vote: I like it +12 Vote: I do not like it

Similar Question for Chef and Moves of GCD: Link

My submission: Link

»
11 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Guess Game could also be simply done in O($$$NloglogN + T\sqrt{N}$$$). If we fix the small number $$$d$$$, the large number can have $$$\lfloor\frac{n}{d}\rfloor-1$$$ values. Also since the answer only depends on $$$d$$$, we can find the range of $$$d$$$ for which $$$\lfloor\frac{n}{d}\rfloor$$$ is constant and add their contribution to answer. It is well known that there are $$$O(\sqrt{n})$$$ distinct ranges.

»
11 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

In Question BREAK THE ARRAY I Dont Know where my code is bugging can anyone please figure it out. It is not able to run even in lower limits of 100 Yet other peoples have did the similar and got AC sub link :- https://www.codechef.com/viewsolution/98819410

»
11 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

1. Transfusion Chain

My Code

2. Alt-Tab

My Code

3. EVacuate to Moon

My Code

4. Boxes

My Code
»
11 months ago, # |
  Vote: I like it +1 Vote: I do not like it

There is an $$$O(n)$$$ solution to PARTITION without using segment trees. Consider the $$$O(n^2)$$$ dp

Naive DP

Transitions can be maintained using monotonic stack.

Efficient DP
  • »
    »
    11 months ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Can you explain this?

»
11 months ago, # |
  Vote: I like it +1 Vote: I do not like it

can someone tell what's wrong in my solution for subtask1 of "Break This Array", soln

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I guess there is a problem while viewing solutions of some participants, can you please look into it. Example of one such user's submission

»
11 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For Problem CAMOG, the editorial says. " We do the $$$2^k$$$ operation for each pair of (number, divisor) below $$$N$$$. It’s well-known that there are $$$\mathcal{O}(N\log N)$$$ such pairs, so a simple upper bound on complexity is $$$\mathcal{O}(2^6 \cdot N\log N)$$$. "

Could you explain why is the number of pairs $$$\mathcal{O}(N\log N)$$$ , I was thinking that it should be something like $$$\Sigma$$$ $$$x^{1/3}$$$. I read somewhere that $$$N^{1/3}$$$ is a good upperbound for the number of divisors.