795 - Sandorf's Cipher
Moderator: Board moderators
795 - Sandorf's Cipher
I think it's a easy problem. Always getting WA. Could someone give me some test case?
Sample Input/Output
Input
1234567890##########1234567890######
###############################12345
Output
851##0851###62##73##974###9#03###642
#########42#######51#######3
1234567890##########1234567890######
###############################12345
Output
851##0851###62##73##974###9#03###642
#########42#######51#######3
invocation
Hello, please, is someone who can send here that solved program? (code) I really, really need it. PLEASE....
Re: 795 - Sandorf's Cipher
Hi,
Can anyone give any critical test case on this? I am getting WA.
Thanks
Here is my code..
Can anyone give any critical test case on this? I am getting WA.
Thanks
Here is my code..
Code: Select all
Got Acc..
Last edited by newkid on Thu Jan 15, 2009 9:27 pm, edited 1 time in total.
hmm..
Re: 795 - Sandorf's Cipher
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:
output:
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
Code: Select all
#########42#######51#######3
#########42#######51#######3
#########42#######51#######3#################42#######51#######3
hmm..
Re: 795 - Sandorf's Cipher
getting wa
Help please
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';
}