Test case for SNCKPB17/SNELECT

Hello All,
I tried to implement code for SNCKPB17/SNELECT, below is the link to it. Can anyone please give me a test case where my code fails? I’m not able to find any such test case though I it got wrong when submitting it.

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

1
msmmmmsssssss

Final configuration after eating will be: mmmmmssssss

Expected output : Snakes.

Your output : Tie.

The error happens as (considering 1 indexing) both of ur mongooese number 1 and 3 are eating snake number 2. Instead only one of them should eat it.

1 Like

Try this test case-

Input
1
msmmssss
Your Output
mongooses
Correct Output
tie

I recommend try convering that ‘s’ to any other char like ‘*’ because i suspect your error is snakes getting reduced twice in case of “m s m” .

1 Like

lmao!

23 second difference b/w our answers. Nice eye mate :slight_smile: XD

1 Like

1
ssssmmsm
Your output: mongooses
Expected Output: tie

Actually your if condition is wrong. First you are checking if ith position has ‘m’ then you are checking if (i+1)th position has ‘s’. But suppose (i+2)th element is ‘m’ then for it, the first if will hold as (i+2-1)th position is ‘s’, which means (i+1)th position is considered twice.
To resolve this, just keep track of a Boolean visit[] array, and mark all the ‘s’ that are visited.

//