chari407's blog

By chari407, history, 4 years ago, In English

We are given n sets of numbers, {1,4}, {4,5}, {1,2,3}. We have to find the minimum number of sets to combine to get the complete set of numbers {1,2,3,4,5}. Also, we should know which sets were selected.

Example: If we choose {1,2,3} & {4,5}, we get the complete set in the minimum most number of steps = 2. If we choose {1,2,3}, {1,4}, {4,5}, we get the complete set of numbers, but we would require 3 steps. How do I solve this problem?

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By chari407, history, 6 years ago, In English

In the tutorial for this problem, I am confused as to why z[i + 1][j + 1] +  = z[i][j] * p is done? Specifically, why are we multiplying p and (1-p) to the previous probabilities? I am a beginner with probabilities and expected value and I didnt understand why " z[i][j] is multiplied with p " . Please explain in detail. Thank You..!

Full text and comments »

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

By chari407, history, 6 years ago, In English

Can someone explain the meaning of "symmetry" and how is that equality assumed in the comment for the editorial of Div2E Tetrahedron

Full text and comments »

Tags #dp
  • Vote: I like it
  • 0
  • Vote: I do not like it

By chari407, history, 6 years ago, In English

Can someone explain the DP solution for Divisibility By Eight ? I didnt understand what was mentioned in the editorial of this problem.

Full text and comments »

Tags #dp
  • Vote: I like it
  • 0
  • Vote: I do not like it

By chari407, history, 7 years ago, In English

This is my submission for Mollys Chemicals. Can someone tell me why it times out ? I calculated the Time complexity as follows — please correct me if I am wrong. 1. The preProcess function would work in O(46 log(46)). 2. The prefix sum computation takes O(n); 3. The subarray generation part (in the while loop) takes O(n^2 * log(46)) . (Because the set size would atmost be 46).

So adding them, O(46 log(46)) + O(n) + O(n^2 * log(46)) and with the constraint over n as 10^5, 46*5 + 10^5 + (10^10)*5.

Assuming 10^9 operations per second, the time limit given for the problem is 2.5 secs which means *2.5 * 10^9 operations can be allowed. Then why does my solution give TLE?

Please help me.

Full text and comments »

  • Vote: I like it
  • -7
  • Vote: I do not like it

By chari407, history, 7 years ago, In English

Can some one help me with this code? I do not know why it is giving me weird values. Code

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By chari407, history, 7 years ago, In English

Hi, I have a couple of doubts. 1. Can we use the standard C++ binary_search() on a stack<> ? 2. Suppose I declare

struct sig
{
int a;
int b;
};

sig temp[10];

stack<sig> trial;

Now I push a few "sig" elements to the "trial" stack. How do I access the second value (b) of the topmost element in the stack ?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By chari407, history, 7 years ago, In English

The problem is as follows: Given an array A1,A2....An, the array is called special if there is any Ai which satisfies either of the following cases: 1. Ai is the median of the subarray [A0,Ai-1], or 2. Ai is the median of the subarray [Ai+1,An-1].

If it is special, print 1, else print 0.

Example: Array is 3,6,8,4. This is special because 6 is the median of [8,4].

How to solve this problem?

Full text and comments »

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

By chari407, history, 7 years ago, In English

Hi, when will FHC 2018 be held? is there any announcement regarding it?

Full text and comments »

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

By chari407, history, 7 years ago, In English

Can some one tell me in detail how to solve this problem — CoinsQuery

Full text and comments »

Tags srm
  • Vote: I like it
  • -8
  • Vote: I do not like it

By chari407, history, 7 years ago, In English

DP doesnt go into my head. I find it difficult to understand always. Any help on this problem would be very much appreciated. Thank you. Boredom

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it