# Need help with Google Code Jam Round 1C Problem A

Can anyone explain the solution of Problem 1(Robot Programming Strategy).

I have done exactly mentioned in analysis. First stored all the program of other robots in vector . Then accessed i-th character of all robot and put it in a set. Then I have checked for 3 cases.

• If set size is 3 (R,P,S) it mean there cannot be any solution with our program can win.

• If size of set is 1 it means that iteration only have 1 value and we can choose corresponding winning value and return the solution

• If size of set is 2 then choose the stronger character (like “R” in “RS”) and proceed till we get size of set 3 or 1 , or our program length reaches 500 .

Here is my solution KJ8ovE - Online C++0x Compiler & Debugging Tool - Ideone.com It would be so grateful if anyone can help me debugging the solution.I have tried downloading working solution of other and tried random test cases but it is working fine.

Try this test case :
4
1
P
PR
SP
SRP

It should give SPR as output but your code is giving impossible.

Strange same code giving different output on different ide. I ran on hackerrank it is giving SPR. On ideone/codechef it is giving IMPOSSIBLE

1 Like

Here is my solution EOl10u - Online Python Interpreter & Debugging Tool - Ideone.com

Damn me. Got my mistake.
set ch;
char curr[501];
int i = 0;
for (auto xx : ch) {
curr[i++] = xx;
}
//curr[i] = ‘\0’; Missed to introduce this terminater.
string cur(curr);

Learning : We should always take care of basics.

1 Like

hey do you qualified for round 2

No . I was unable to debug above silly mistake.

No problem same story here…I just forget to stop checking for strings which are knocked out…

Yes , I have qualified for round 2

Congrats . What was your rank?

thanks man