Getting WA in Devu and his class

Problem link: http://www.codechef.com/problems/DEVCLASS

I have read the editorial of this problem very carefully and write the code for it But I am getting WA for all subtasks. Please tell me what is wrong with my code.
Here’s my solution link: http://www.codechef.com/viewsolution/6579125

Check your code for these test cases:

2
GGBB
2
GGBGBBBBGGGGBB
1
GBGB
0
GGGBGBBB

Your code gives Wrong Output for these test cases and more…

**Here you can see the comparision:

Test Cases:**

100
2
GBGGBGGGBGGBBG
2
GGBB
0
BBGGBGBGBGBB
2
BBBGBBBG
2
GGGBBGBGGBBBBB
2
BBGG
0
GGGGBBGGBBG
2
GBBG
2
BGGBBGBBGBBB
1
GGGGGBGBBG
2
BBBGBGB
1
BBBBBGGBBGGGBB
1
GBGGGBBBB
0
BGGGBBB
2
GGBGBBBBGGGGBB
2
GG
1
GGGBGBGGBBGG
0
BB
1
BBG
0
BBB
2
GGBBGBGBG
0
BBBBGGBBBBGGB
1
BGBGBGG
1
GBGGBGGGBGBG
1
GBGB
2
GG
0
GGBBGBGG
1
GB
1
GGBBBBBGG
0
GBGGBGBBG
0
GGBGBGGGBGGGBB
0
GBGBBBG
0
BGBGB
2
GG
0
GGGBBGBGBBBBG
0
GGGBGBBB
0
BBG
0
BGGBBGG
2
GBBGGBGBGGB
2
GBGBBG
2
GBGBGGGG
1
BG
0
GBBBGBGGBB
2
BBGBBBGBG
0
B
0
BGGB
0
BBBGGGGG
1
BBBBGBBGBBGGG
0
G
1
GGBGGBGGBGGGGB
2
GBGGBBGGGB
2
GB
0
GBBGGBBGBBGG
0
BGBBG
0
GGBGBGG
2
BGBBG
0
BBGBGGBBGGBB
1
GBGBBBG
0
BGBGBG
1
GBG
1
GBBGBGBBBBGGGB
0
GGBBBBBGGBBB
2
BBBGBBGBB
0
B
0
BBBBGGBGGBGB
1
GGB
2
GGBBGBGBGBGGB
2
GBBGGBBGGBBB
1
BB
0
BBBBBGGBBBBG
0
G
1
GBBBB
2
BGG
0
GGBGBGGGBGBBB
0
GGBBGGBGGG
0
GBBGBGGBGGBBG
1
GGGBGGGBB
0
GBGGBGB
0
GBBBBBBGGBGBG
2
BBGBGGGBBBBB
2
BBBB
1
BB
2
BBGGGGBBG
0
BG
1
BGBGBGGBBG
0
GBBGGBGGBB
0
B
1
BBGBG
0
GGGBBBBG
2
BBBBGBB
0
BGGGGGGG
0
BG
0
BBGGGBG
2
BGG
0
BG
2
GGGBBGGBBGB
1
GBGG
0
BBGGGGBBBBBBG
1
BGBB
1
BBBG

**Output of Your code
**

-1
3
-1
-1
-1
1
-1
1
-1
-1
-1
-1
7
1
9
-1
-1
-1
1
-1
1
-1
3
-1
2
-1
-1
1
6
2
-1
3
0
-1
3
3
1
2
2
2
-1
0
-1
-1
0
1
-1
-1
0
-1
-1
1
3
1
-1
1
-1
3
0
0
-1
-1
-1
0
-1
1
2
-1
-1
-1
0
-1
1
5
-1
3
-1
2
-1
-1
-1
-1
4
0
1
3
0
2
2
-1
-1
0
1
1
0
7
-1
-1
-1
-1

**Expected Output:
**

-1
1
-1
-1
-1
1
-1
1
-1
-1
-1
-1
7
1
6
-1
-1
-1
1
-1
1
-1
3
-1
0
-1
-1
0
6
2
-1
3
0
-1
3
1
1
2
2
1
-1
0
-1
-1
0
1
-1
-1
0
-1
-1
0
3
1
-1
1
-1
3
0
0
-1
-1
-1
0
-1
1
2
-1
-1
-1
0
-1
1
5
-1
3
-1
2
-1
-1
-1
-1
4
0
1
2
0
2
2
-1
-1
0
1
1
0
7
-1
-1
-1
-1

Check them out… You’ll find a lot of test cases where your code fails…

Happy Debugging… :slight_smile:

1 Like