Page 1 of 1

12337 - Bob's Beautiful Balls

Posted: Fri Jan 31, 2014 11:41 pm
I keep getting WA for this problem. I'm transforming the string into a matrix (spiral) and then comparing checking if each column has only one color.

I tried these cases myself
Sample Input
7
BGWBBGGGBBWGBBGWBB
GBBWBBWBBB
BBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWW
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGG
BGWBBGGGBBWGBBGWBBB
BBBBWWBBBB
Output for Sample Input
Case 1: 9
Case 2: -1
Case 3: 8
Case 4: -1
Case 5: 20
Case 6: 7
Case 7: -1
Case 8: 7
Can anyone help with more test cases that I can check?

Thank you

Re: 12337 - Bob's Beautiful Balls

Posted: Sun Feb 02, 2014 3:11 am
Your input testcases should be 8, I'm guessing that's a typo.

Try these:

Input:

4
BBBB
BB
BGGB
WWBWW

Output:

Case 1: 4
Case 2: -1
Case 3: 4
Case 4: -1

Keep in mind, If there is more than one N & M solution, the lowest sum is the answer.
Also if N = 6 and M = 3 does give you -1, maybe N = 3 and M = 6 works. So try the 2nd if the first doesn't give a beautiful grid.

Thanks for the cases, helped me a lot ;D

Re: 12337 - Bob's Beautiful Balls

Posted: Sun Feb 02, 2014 3:17 am

Thanks though

Re: 12337 - Bob's Beautiful Balls

Posted: Sun Feb 02, 2014 3:58 am
Try this:

Input:

1
GGGGGGGGGGGGGGGGGGGGGGGG

Output:

Case 1: 10

Re: 12337 - Bob's Beautiful Balls

Posted: Sun Feb 02, 2014 6:22 am
Solved it finally!!

I was failing on this case!

BGWWWWWGBBBBGGG