Hey guys , I am getting wrong answer in : http://www.spoj.pl/problems/HASHIT/. Somebdy plz check it out or provide some test cases. This code works fine with the test cases provided and even my own test cases.
The following is my code: #include<stdio.h> #include<string.h> int main() { int num_tcases,num_ops,i,j,k,l,n,x,m,y,count; int occupied[101]; char table[101][16]; char temp[20],temp1[20]; scanf("%d",&num_tcases); for(x=0;x<num_tcases;x++) { count=0; scanf("%d",&num_ops); for(i=0;i<101;i++) { occupied[i]=0; } for(i=0;i<num_ops;i++) { scanf("%s",&temp); n=0; for(j=1;j<=(strlen(temp)-4);j++) { n=n+j*temp[j+3]; } n=19*n; n=n%101; y=n; if(temp[0]=='A') { l=1; label: if(occupied[n]==0) { j=4;k=0; while(temp[j]!='\0') table[n][k++]=temp[j++]; table[n][k]='\0'; occupied[n]=1; count++; } else if(occupied[n]==1) { temp1[0]='A'; temp1[1]='D'; temp1[2]='D'; temp1[3]=':'; m=0; while(table[n][m]!='\0') { temp1[m+4]=table[n][m]; m++; } temp1[m+4]='\0'; //strcat(temp1,table[n]); //printf("\n%s",temp1); if(strcmp(temp1,temp)!=0) { if(l<20) { n=y+l*l+23*l; n=n%101; l++; goto label; } } } } else if(temp[0]=='D') { l=1; label1: if(occupied[n]==0) { if(l<=20) { n=y+l*l+23*l; n=n%101; l++; goto label1; } } else if(occupied[n]==1) { temp1[0]='D'; temp1[1]='E'; temp1[2]='L'; temp1[3]=':'; m=0; while(table[n][m]!='\0') { temp1[m+4]=table[n][m]; m++; } temp1[m+4]='\0'; //strcat(temp1,table[n]); //printf("\n%s",temp1); if((strcmp(temp1,temp)!=0) && (occupied[n]==1)) { if(l<=20) { n=y+l*l+23*l; n=n%101; l++; goto label1; } } else if((strcmp(temp1,temp)==0) && (occupied[n]==1)) { occupied[n]=0; count--; } } } } printf("\n%d",count); for(i=0;i<101;i++) { if(occupied[i]==1) { printf("\n%d:",i); printf("%s",table[i]); } } } return 0; } -- 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.