RE in Chef and Alphabets(WANNABET)

https://www.codechef.com/CHIL2020/problems/WANNABET/ I did this question using ordered_set but its giving run-time error, sample test cases are passing on my compiler, I am not able to figure out the mistake. please help :pensive:
here is the link to my submission

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

2 Likes
int d;
				d--;
				char ch;
				cin >> d >> ch;

You probably want the d-- to be performed after you read in the d :slight_smile:

3 Likes

In line number 95 the the index that are inserted are 0 based but when you are trying to access them in line 108, the indexing is 1 based.
Just add a d-=1 before line 108 and your code is GTG!
I’ve tested it on the server. It’s giving AC.

3 Likes

Exactly!!

3 Likes

How dumb I am
Thank you very much!
I wasted 1.5 hours in it, U literally saved my 2-3 hours :slightly_smiling_face:

4 Likes

I didn’t paid attention to 10^4 and coded it using fenwik tree :confused: