ANUMLA - Editorial

please add solutions…

Solutions are not opening, check the links please

it’s ok now :wink:

very well written :slight_smile:

Very nice explanation :slight_smile:

Hey @yogeshkr0007 have a look this testcase is the one to which your solution is wrong

1 Like

hey.
i edited the link.
same situ though.
thanks anyways.

The concept is quite nice. I tried to implement exactly the same thing in code. However, I did not know about the container, and hence my solution became very complicated. :frowning:

Why are you removing both 2’s??It’s a multi-set, so only one instance of 2 will be removed and then it will become {2,3,3,4}.

May you please tell me how you got 0 0 1 1 1 1 2 2 by adding the elements of subsets of set={0,1,0} in your given test case as the possible subsets are {},{0},{1},{0,1},{1,0},{0},{0,1,0},{0,0} and the array formed is 0 0 1 1 1 0 1 0.Correct me if I am wrong.

nope…u havent!!!

2 Likes

Take a test case:
1
3
0 1 2 3 4 5 6 7
Ans: 1 2 4.
So this logic fails.

@hkbharath The test case you provided is wrong and does not satisfies the constraints in the first place. It is clearly give that the original array can only consist of positive integers, hence you cannot have more than one 0’s in the test case itself.

for array [1,2,4] possible subset {0},{1},{2},{4},{1,2},{2,4},{1,4},{1,2,4} . According to this line "Then for each subset, he calculated the sum of elements in that subset and wrote it down on a paper ". so the input will be: 0,1,2,4,3,6,5,7 ( in any order). @johri21 how you got that test case ?

That is because count() is linear in time.Refer this link
I guess overall complexity is increased to O((2^n)log(2^n)(number of subsets at that time)).

okay so take input

0 1 2 4 3 6 5 7
and your program would produce erroneous output
1 2 3
instead of correct output
1 2 4

1 Like

@bajaj6 You will have T=1 N=3 than 0 1 2 3 4 5 6 7. I think you were not able to get T=1 and N=3. :slight_smile:

My corrected sol : CodeChef: Practical coding for everyone

@prakharmy @johri thank you. understood

It is clearly given that the original array can only consist of positive integers, hence you cannot have more than one 0’s in the test case itself.

And haven’t you read the editorial? You can’t subtract the first element from all the elements, because they may or may not contain the value of the first element in their sum.