Hi, I had implemented the code in the same way but I printed the output in the order the jobs arrived in the input not the sorted one which I implemented in the code. That's how I was able to solve the problem. Thanks and Regards, Nikhil Kataria
On Tue, Apr 7, 2020 at 6:13 AM DEVANSH CHAUDHARY <[email protected]> wrote: > #include <stdio.h> > int main(){ > int t,x=1; > scanf("%d",&t); > while(t--) > { > int n,i,j,d=0; > scanf("%d",&n); > int s[n],e[n]; > char p[n]; > for(i=0;i<n;i++) > { > scanf("%d",&s[i]); > scanf("%d",&e[i]); > } > > p[0]='C'; > for(i=1;i<n;i++) > { > d=0; > for(j=0;j<i;j++) > { > if(p[j]=='C') > { > if((s[i]<e[j]&&s[i]>s[j])||(e[i]<e[j]&&e[i]>s[j])) > { > d=1; > break; > } > } > } > if(d==0) > p[i]='C'; > else > p[i]='J'; > } > d=0; > for(i=0;i<n;i++) > { > for(j=i+1;j<n;j++) > { > if((p[i]=='J')&&(p[j]=='J')&&(i!=j)) > { > if((s[i]<e[j]&&s[i]>s[j])||(e[i]<e[j]&&e[i]>s[j])) > { > d=1; > break; > } > } > } > if(d==1) > break; > } > > if(d==0) > { > printf("Case #%d: ",x); > for(i=0;i<n;i++) > { > printf("%c",p[i]); > } > > > printf("\n"); > x++; > } > else > { > printf("Case #%d: IMPOSSIBLE\n",x); > x++; > } > > } > return 0; > } > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/d96eb8ec-4094-47c4-a0da-f6e03f8e22a0%40googlegroups.com > <https://groups.google.com/d/msgid/google-code/d96eb8ec-4094-47c4-a0da-f6e03f8e22a0%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAMRonoepB4_5vUPBVCOjdFgs449RqRhuSOdmR9oakcd7Z9MXgQ%40mail.gmail.com.
