Page 1 of 1

795 - Sandorf's Cipher

Posted: Sat Jun 05, 2004 7:03 am
by htl
I think it's a easy problem. Always getting WA. Could someone give me some test case?

Sample Input/Output

Posted: Tue Jul 20, 2004 3:34 pm
by Yeomin
Input

1234567890##########1234567890######
###############################12345

Output

851##0851###62##73##974###9#03###642
#########42#######51#######3

invocation

Posted: Sun Jan 06, 2008 11:52 am
by Bunda001
Hello, please, is someone who can send here that solved program? (code) I really, really need it. PLEASE....

Posted: Sun Jan 06, 2008 12:02 pm
by sohel
Could you please elaborate as to why you desperately need the code as opposed to some hints?

answer

Posted: Wed Jan 09, 2008 10:11 am
by Bunda001
I wont lie - i need that program to school and i am not a great programmer, so i need help. If you think, that i should do it myself, ok, but people should help each other - and i need it. So thats why. thank you for help....

Re: 795 - Sandorf's Cipher

Posted: Thu Jan 15, 2009 2:08 pm
by newkid
Hi,
Can anyone give any critical test case on this? I am getting WA.

Thanks

Here is my code..

Code: Select all

 Got Acc..

Re: 795 - Sandorf's Cipher

Posted: Thu Jan 15, 2009 9:26 pm
by newkid
Found my bug..

I was compressing the decrypted string from the end if it had '#' there.. I was wrong here.. This should be done after the whole message is decrypted..

the following input might help..
input:

Code: Select all

###############################12345
###############################12345

###############################12345###############################12345
output:

Code: Select all

#########42#######51#######3
#########42#######51#######3

#########42#######51#######3#################42#######51#######3

Re: 795 - Sandorf's Cipher

Posted: Sat Oct 17, 2015 10:50 am
by robin_0
getting wa :(
Help please :(

Code: Select all

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define OUTPUT freopen("myfile.txt","w",stdout);
#define INPUT freopen("input.txt","r",stdin);
#define MAX 100005

char inp[1005],op[1005];

void decrypt ( int pointer );

int main()
{
    int i,pointer,len,j,bound;

    while(gets(inp))
    {

        len=strlen(inp);
        if(len==0)
            printf("\n");


        for(pointer=0;pointer*36<len;pointer++)
            decrypt(pointer);

        //printf("%d\n",pointer);
        j=(pointer)*36;


        for(i=0;i<len;i++)
        {
            if(op[i]!='#')
            break;
        }


        bound=i;

        //printf("%d\n",bound);

        for(i=len-1 ;i>=bound;i--)
            printf("%c",op[i]);

        printf("\n");
    }


    return 0;
}


void decrypt ( int pointer )
{
    int i=pointer*36;
    op[i+0]=inp[i+1];
    //printf("%c",inp[1]);
    op[i+1]=inp[i+3];
    op[i+2]=inp[i+5];
    op[i+3]=inp[i+10];
    op[i+4]=inp[i+14];
    op[i+5]=inp[i+19];
    op[i+6]=inp[i+22];
    op[i+7]=inp[i+29];
    op[i+8]=inp[i+33];
    op[i+9]=inp[i+8];
    op[i+10]=inp[i+11];
    op[i+11]=inp[i+15];
    op[i+12]=inp[i+18];
    op[i+13]=inp[i+23];
    op[i+14]=inp[i+26];
    op[i+15]=inp[i+28];
    op[i+16]=inp[i+31];
    op[i+17]=inp[i+35];
    op[i+18]=inp[i+2];
    op[i+19]=inp[i+6];
    op[i+20]=inp[i+13];
    op[i+21]=inp[i+16];
    op[i+22]=inp[i+21];
    op[i+23]=inp[i+25];
    op[i+24]=inp[i+30];
    op[i+25]=inp[i+32];
    op[i+26]=inp[i+34];
    op[i+27]=inp[i+0];
    op[i+28]=inp[i+4];
    op[i+29]=inp[i+7];
    op[i+30]=inp[i+9];
    op[i+31]=inp[i+12];
    op[i+32]=inp[i+17];
    op[i+33]=inp[i+20];
    op[i+34]=inp[i+24];
    op[i+35]=inp[i+27];
    //op[i+36]='\0';


}