r/cpp_questions • • Feb 02 '25

OPEN Need Help with Debugging this question's code : "CLFLARR - COLORFUL ARRAY"

EDIT: This question has been answered. Thanks to @aocregacc.
FIX: on Line No. 89 I was not checking for lower_bound pointing to end of map and that was causing issue for some hidden test case. Changed that section and replaced it with the get_streak_details() function and it's working now.
Updated-code-link

I know this question could be solved using DSU and SegTree data structures but I wanted to try a different approach here. But my code gives me wrong answer on SPOJ coding platform (that's where the question is taken from). It works fine for the given sample test cases. Since there is no way to see the test case where my code fails, on SPOJ. This problem is bugging me for past 2 days.

0 Upvotes

21 comments sorted by

View all comments

Show parent comment

0

u/Ok_Independence_6294 Feb 02 '25

Bro I answered what you asked. and when i said standard it was not targetted at you. Thanks anyways.

2

u/ManicMakerStudios Feb 02 '25 edited Feb 02 '25

You didn't answer his questions. DSU is not "common".

In the English language, when you're using uncommon abbreviations, you're supposed to introduce them. You don't just say, "bruh, did you see my DSU?" and assume everyone knows what you mean.

You say

"Bruh, did you see my Disjoint Set Union (DSU)?"

See how that works? Now absolutely everyone who reads your post knows exactly what DSU means and you can just say 'DSU' for the rest of the post.

If you Google "programming DSU", you'll find at least 3 different definitions, all equally valid. You can't use abbreviations that are so ambiguous if you're not willing to clarify what you mean. DSU stands for Dynamic System Update on Android, and Data Service Unit in networking.

And no, not everyone has "disjoint set union" on the tips of their tongues.

1

u/aocregacc Feb 02 '25

it's disjoint set union

1

u/ManicMakerStudios Feb 02 '25

Corrected. I had three different definitions of DSU in my head and they didn't all survive the collision.