- Code: Select all
#include<stdio.h>
#include<string.h>
#define max(a,b) ((a)>(b)? (a): (b))
#define min(a,b) ((a)>(b)? (b):(a))
int CheckTheInformation(char input[],long int x , long int y){
long int i ;//long long int(used while sending to the judge )
int count;
count=input[x];
for(i=x+1;i<=y;i++){
if(input[i]==count)
continue;
else
return 0;
}
return 1;
}
int main(){
char input[1000002];
char xtra[50];
int cases,flag,count;
long int i , j;//long long int(used while sending to the judge )
cases=1;
while(gets(input)){
if(strcmp(input," ")==0 || strcmp(input,"\n")==0)
break;
gets(xtra);
sscanf(xtra,"%d",&count);
printf("Case %d:\n",cases);
while(count>0)
{
gets(xtra);
sscanf(xtra,"%ld %ld",&i,&j);//long long int
flag=CheckTheInformation(input,min(i,j),max(i,j));
if(flag==0){
printf("No\n");
}
else
printf("Yes\n");
count--;
}
cases++;
}
return 0;
}
on the other hand my code for 10340 fetches me WA . the algorithm of mine is very simple , i cant find any mistakes in the code . pliz help .
here is the code for 10340
[c]
#include<stdio.h>
#include<string.h>
int CheckForSubSequence(char in1[],char in2[]){
int i , c , flag,j;
if(strlen(in1) > strlen(in2)){
return 1;
}
else if(strlen(in1)==strlen(in2)){
return strcmp(in1,in2);
}
else{
for(i=0,c=0;in1[i]!='\0';i++){
flag=1;
for(j=c;in2[j]!='\0';j++){
if(in1[i]==in2[j]){
c=j;
flag=0;
break;
}
}
if(flag==1)
return 1;
else
continue;
}
return 0;
}
}
int main(){
char input[10000];
char in1[1000],in2[1000];
int Flag;
while(gets(input)){
sscanf(input,"%s %s",in1,in2);
Flag=CheckForSubSequence(in1,in2);
if(Flag==0){
printf("Yes\n");
}
else
printf("No\n");
}
return 0;
}[/c]
pliz help me
Riyad


