(Que - ENGLISH) I am getting wrong for only one test case and I am unable to find that?

My code link:
https://www.codechef.com/viewsolution/29018283

If possible please give counter example.

Code logic:
add to map and count frequency.
match the same and add score to final_score add remaining will be added to vector v
calculate score of every pair from v and if score is >0 add to vector score along with ids of string
sort vector score based on scores
take pair by pair untill all is selected or all pairs are checked

Input

2 equal words of length 50000

Incorrect output generated by your code
-1794967296

Correct output
2500000000

Correction

@line 16 : int changed to ll
Here’s your corrected code.

Hope this helps. :slight_smile:

2 Likes

just use long long int instead of int at every place
Corrected AC Code:
https://www.codechef.com/viewsolution/29074035

1 Like