11661 - Burger Time?
Posted: Sun Sep 06, 2009 6:12 am
remove...........
INPUT:Take input as integer and
TRY this case .........
I think this will helpful.....4 u
Code: Select all
12
DDDDRRRRZDRD
0
Code: Select all
0
What an ugly code, why didn't you useMRH wrote:your given input my code give correct output but Again i gwt WA
plz help me.
thanks in advance
Code: Select all
?
Glance of my eyes tells that your reading input is incorrect. Try to read everything once. :wink:
Code: Select all
#include<cstdio>
#include<string>
#define MAX 99999999
int main(){
long L,min,inicio,j;
bool encontreZ;
char *calle;
while(true){
scanf("%li",&L);
fflush(stdin);
if(L==0) break;
calle=new char[MAX];
scanf("%s",calle);
fflush(stdin);
if((long)strlen(calle)!=L) L=(long)strlen(calle);
min=MAX;
for(int i=0;i<L;i++){
if(calle[i]!='.'){
encontreZ=false;
if(calle[i]=='Z'){
min=0;
encontreZ=true;
}
else if(calle[i]=='D'){
j=i;inicio=i;
for(j=j+1;j<L;j++){
if(calle[j]=='R'){
if((j-inicio)<min) min=j-inicio;
i=j;
break;
}
else if(calle[j]=='D'){
i=j;inicio=j;
}
else if(calle[j]=='Z'){
encontreZ=true;
min=0;
break;
}
else{}
}
}
else{
j=i;inicio=i;
for(j=j+1;j<L;j++){
if(calle[j]=='D'){
if((j-inicio)<min) min=j-inicio;
i=j;
break;
}
else if(calle[j]=='R'){
i=j;inicio=j;
}
else if(calle[j]=='Z'){
encontreZ=true;
min=0;
break;
}
else{}
}
}
if(encontreZ==true) break;
}
}
printf("%li\n",min);
fflush(stdout);
delete []calle;
}
return 0;
}
Code: Select all
At last Accepted .