Why do I get a runtime error?

http://www.codechef.com/viewsolution/6584476

Based on some debugging, I realized that when I go in for the 3rd loop to get the string it has an error. Why is that? Is it some over memory? Please help me!

hey @dtb_uday

First error which i can spot visually is,

See this part else if**(b=g+1)** in below code:

```
if(b+1==g || g+1==b)
{
if(b+1==g)
{
start='B';
}
else if**(b=g+1)**
{
start='G';
}
```

It should be:

```
else if (b==g+1)
```

Secondly:

```1
1
BGG
```

Running:

```After taking Input:

if(b+1==g || g+1==b) ----- [ (b+1==g)=True as (1+1==2)=True ]
if(b+1==g)
{
start='B';
}
else if(b==g+1)
{
start='G';
}

-------------------------here start='B'
then

for(int i=0;i girl=<>

loop Ends

Now:
Next Loop

for( int i=0 ; i<boy.size() ; i++ )
{
int temp=boy[i]-girl[i];
....

```
```    ---- Here boy.size() is greater than 0 but girl.size()=0
----but you are trying to access girl[0] and this is where your code fails!!
```

Hope you understoodâ€¦ Try to debug the codeâ€¦