Problem Name: Cryptopangrams
It was running fine on Code Blocks IDE

On Mon, Apr 8, 2019, 4:46 AM 'Pablo Heiber' via Google Code Jam <
google-code@googlegroups.com> wrote:

> Hi,
>
> You are welcome to do with your code whatever you want after the round is
> over, including posting it in this mailing list for help. As you probably
> saw, many others did.
>
> Best,
> Pablo
>
> On Sun, Apr 7, 2019 at 6:27 AM ACTECH <ayanchowdhury2...@gmail.com> wrote:
>
>> I had participated in codejam 2019,
>> I solved 3 problems , However 1 problem got Runtime error in the platform
>> while it was running fine in my platform
>>
>> --
>> 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 google-code+unsubscr...@googlegroups.com.
>> To post to this group, send email to google-code@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-code/a50bdeab-e05e-45b4-80d6-089939a2302a%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 google-code+unsubscr...@googlegroups.com.
> To post to this group, send email to google-code@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/CANa5jcAxSSC9HW%2B_Z%2BBNdLxG6-AhQF3NgtqL%3DpucSssg4sx%3Ddw%40mail.gmail.com
> <https://groups.google.com/d/msgid/google-code/CANa5jcAxSSC9HW%2B_Z%2BBNdLxG6-AhQF3NgtqL%3DpucSssg4sx%3Ddw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 google-code+unsubscr...@googlegroups.com.
To post to this group, send email to google-code@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CANQWH3D%2BfpYCkPANMsCSS42j0C-dJ%2B3YtJwcwQBTV-ANWaYzbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
#include <stdio.h>
#include <stdlib.h>
int search(int *,int);
void sort(int *);
void isSafe (int , int *);
int main()
{
    int T;
    scanf("%d",&T);
    for(int Test=1;Test<=T;Test++){
        int Zprime,width,a0,a1;
        scanf("%d %d",&Zprime,&width);
        int identity[26]={0};
        int *Repeated=(int *)malloc(sizeof(int)*(width+1));
        int *OriginalPan=(int *)malloc(sizeof(int)*width);
        for(int i=0;i<width;i++)
            scanf("%d",&OriginalPan[i]);
        for(int i=2;i<=OriginalPan[0]/2+1;i++)
            if(OriginalPan[0]%i==0){
                a0=i;
                break;
            }
        a1=OriginalPan[0]/a0;
        if(OriginalPan[1]%a0==0){
            Repeated[0]=a1;
            Repeated[1]=a0;
            Repeated[2]=OriginalPan[1]/a0;
        }
        else{
            Repeated[0]=a0;
            Repeated[1]=a1;
            Repeated[2]=OriginalPan[1]/a1;
        }
        isSafe(Repeated[0],identity);
        isSafe(Repeated[1],identity);
        isSafe(Repeated[2],identity);
        for(int i=2;i<width;i++){
            Repeated[i+1]=OriginalPan[i]/Repeated[i];
            isSafe(Repeated[i+1],identity);
        }
        sort(identity);
        printf("Case #%d: ",Test);
        for(int i=0;i<=width;i++){
            int pos=search(identity,Repeated[i]);
            printf("%c",65+pos);
        }
        printf("\n");
        free(OriginalPan);
        free(Repeated);
    }
    return 0;
}
void isSafe(int item,int * identity){
    if(identity[25]!=0)
        return;
    int i;
    for(i=0;identity[i]!=0;i++)
        if(identity[i]==item)
            return;
    identity[i]=item;
}
int search(int *identity,int item){
    int i;
    for(i=0;i<26;i++)
        if(item==identity[i])
            return i;
    return i;
}
void sort(int *identity){
    for(int i=1;i<26;i++){
        int j=i-1;
        int key=identity[i];
        while((j>=0)&&(identity[j]>key)){
            identity[j+1]=identity[j];
            j--;
        }
        identity[j+1]=key;
    }
}

Reply via email to