MINOPS - Editorial

(https://www.codechef.com/viewsolution/32129967)

what is wrong in this solution . please tell atleast one test case

https://www.codechef.com/viewsolution/32137726
Why is this code giving segmentation fault? Please Help;

Clean understandable editorial specially observations its awesome Thanks!!

1 Like

I did it the editorial solution way, and saw some people doing it using priority queue as well. Still got WA in both, what am I missing?
Approach 1: https://www.codechef.com/viewsolution/32136784
Approach 2: https://www.codechef.com/viewsolution/32137788

Your code gives segmentation fault for the test case where both the strings are equal as vector ind will be empty and line 20 will make illegal reference and give sigsev

Yes, you are right, Thanks a lot :sweat_smile:

Anyone have any good test cases for this ?
@rajarshi_basu

There are many cases which you can make if you understand the problem. To be very honest, you yourself can prove that your algorithm is wrong after some serious thinking. There are many areas in which a person can get a WA. Maybe if you will show me your code (if that is the reason why you are asking for test cases, i donā€™t know) I can help you.

Overall, this problem was a beauty. The setter @rumblefool nailed it, and editorialist @rajarshi_basu also nailed it in trying to explain the outline of this solution. Kudos to the tester @raja1999 for ensuring strong test cases.

1 Like

@aryan12 Can you kindly give me some strong test cases for this problem?
I have tested it on several but in vain.

Thanks in advance.

2 Likes

Great question. Can anyone point me to similar questions?

1 Like

I am afraid, but that is the wrong link.

Anyways I guess this is the link you are asking for.

Your input is wrong, see the method of inputting. You donā€™t have to input n, for simplifying purposes n is mentioned in the question.

The Input is
T
a
b
ā€¦For T test cases (input a and b)

First thing,Thanks thanks thanks a lot.
Second thing,how did you then figure out my solution if the link was wrong?
Third thing,this is my problem that even if I come up with algos,these mistakes just kill my hard work.How to improve in this matter?I had read the question 5 to 6 times,still made this mistake
If you have any suggestions ,kindly give me .because I also want to be a good coder.

1 Like

For the first thing, You are welcome :slight_smile:.

For the second thing, there is something called Google / search engines.

For the third thing, This happens with me also. And in fast problem solving, you often forget or mess up the format of input. It happens with practice. Eg. With this happening, you will now never forget not to look at the Input section for the format.

Thanks Sir

1 Like

ok @rajarshi_basu Sir, I want to discuss another approach.We sort the lengths of segments having similar character as the you have pointed out.Now what I try to do is that check whether these lengths when added whether decreases the the term KL or not.If not then we simply break out from the loop that iterates over this length.Otherwise the length is added to the value of total number of chars to be replaced and K decreased by 1.The condition to check for the inclusion is tested in the way that
whether current length of chars to be replaced>=length I want to add
(K-1)?
Bcz when we add that length, K*L decreases by L and increases by (K-1)*no. of chars to be added to L.
If any length cannot be included,no length larger than this cannot also be included.
Is there anything wrong with the approach?
I am also attaching the link to solution.
https://www.codechef.com/viewsolution/32167102

https://www.codechef.com/viewsolution/32167873
Need a test case that doesnā€™t work for my solutionā€¦@rajarshi_basu

My code is producing right output for this one also. But still WA. Please help.

https://www.codechef.com/viewsolution/32175091

Anyone who could help in debugging my code will be awarded a princely state in the Ottoman Empire. Thank You in advance.
MINOPS
PS: Iā€™m facing wrong answer! @rajarshi_basu

Editorials should be like this. Kudos to @rajarshi_basu :grin: :grin:

1 Like

I am not sure whether that breaking condition is okay or not. there is probably no monotonicity condition that we can apply here, hence that assumption that once if it doesnt decrease, it will never decrease, is wrong.