@ kartik sachan
Problem with this code is this-
All GB pairs should be process in one time period


On 6/23/11, kartik sachan <kartik.sac...@gmail.com> wrote:
> QUESTION LINK IS http://www.spoj.pl/problems/SHLIGHTS/
>
> MY CODE IS GIVEN BELOW
> ITS IS GIVING TLE................PLZZ HELP ME OUT
>
> # include<cstdio>
> # include<cstring>
> int main()
> {
>
> int t;
> char a[100007];
> scanf("%d",&t);
> int i,j,k;
>
> while(t--)
>     {
>         int count=0;
>         int flag=0,flag1=0;
>
>         scanf("%s",a);
>         while(1)
>         {
>
>             for(i=0;a[i]!='\0';i++)
>                     if(a[i]=='G'&&a[i+1]=='B')
>                         {a[i]='B';a[i+1]='G';i=i+1;flag1=1;}
>             if(flag1==1)
>             {count++;flag1=0;}
>             if(count <=flag)
>             break;
>             flag=count;
>         }
>     printf("%d\n",count);
>     }
> return 0;
> }
>
>
>
> PLZZ HELP ME OUT OR SUGGEST ANY OTHER LOGIC IF IT  HAS SOME MISTAKES
>
> --
>
> *WITH REGARDS,*
> *
> *
> *KARTIK SACHAN*
>
> *B.TECH 2ND YEAR*
> *COMPUTER SCIENCE AND ENGINEERING*
> *NIT ALLAHABAD*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to