ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1101. Robot in the Field

Please check test#5, i think it wrong.
expression contains successively two registers without the operator between them.
Test is correct (-)
Posted by Vladimir Yakovlev (USU) 2 Aug 2006 15:18
thanks... but why this code get CRASH(INT_.....ZERO) ?
#define S        32768

inline bool sc(char*a,char*b){
while(*a==*b)++a,++b;
return *b==0;
}
............
............
char s[S],*j;
{char a[S];
gets(a);
char *i;
for(i=a;*i;++i)if(*i>='a' && *i<='z')*i+='A'-'a';
for(i=a,j=s;*i;){
if(sc(i,"NOT"))*(j++)='!',i+=3;
else if(sc(i,"AND"))*(j++)='&',i+=3;
else if(sc(i,"OR"))*(j++)='|',i+=2;
else if(sc(i,"TRUE"))*(j++)='1',i+=4;
else if(sc(i,"FALSE"))*(j++)='0',i+=5;
else if(*i>='A' && *i<='Z' || *i=='(' || *i==')')
*(j++)=*(i++);
else ++i;
}
*j='*';
#define IsReg(x)    (x>='A' && x<='Z' || x=='0' || x=='1')
for(i=s;*i!='*';++i)
if(IsReg(i[0]) && IsReg(i[1])){
*i/=*i-*i;
}
}
............
............

Edited by author 02.08.2006 15:47
sorry... bug would in my code... :(
if the last word FALSE or TRUE, then this fucntion returun wrong result...
inline bool sc(char*a,char*b){
while(*a==*b)++a,++b;
return *b==0;
}