ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1438. Time Limit Exceeded

Test 12. Is it correct?
Posted by Burunduk1 4 Jun 2006 22:15
There are two labels in one string!
I tried to prove it but failed (+)
Posted by Dmitry 'Diman_YES' Kovalioff 4 Jun 2006 23:23
For each string S of input I used the following checking procedure:

   n:=0;
   for p1:=1 to length(S) do inc(n,ord(S[p1]=':'));
   if n>1 then halt(1);

But my program is still AC. It means that there is no string with two or more ':' inside.

Could you explain what does "two labels in one string" mean? You might give an example of such incorrect string.
Re: I tried to prove it but failed (+)
Posted by Burunduk1 4 Jun 2006 23:30
S = Str, ff = 0;
lmn:
sscanf(S, "%s", Lab);
if (Lab[(len = strlen(Lab)) - 1] == ':')
{
if (ff) while (1);
Low(Lab);
Lab[len - 1] = 0;
if ((i = GetObj(Lab)) == -1)
AddObj(Lab, ComN);
else
ObjVal[i] = ComN;
S += len;
ff = 1;
goto lmn;
}

Gets TLE 12, but without "if (ff) while (1);" it gets AC.

PS: without "goto lmn;" it gets WA 12.

Edited by author 04.06.2006 23:42
Re: I tried to prove it but failed (+)
Posted by Vladimir Yakovlev (USU) 4 Jun 2006 23:44
Your code reads one label twice!
sscanf(S, "%s", Lab) skips spaces in the beginning of line, but S+=len doesn't skip.
Re: I tried to prove it but failed (+)
Posted by Ivankov Dmitry 4 Jun 2006 23:48
"S += len" is wrong ;)
Re: I tried to prove it but failed (+)
Posted by Burunduk1 4 Jun 2006 23:49
Thank you :)

PS: I repeat this bug again and again :(
Re: Test 12. Is it correct?
Posted by Fyodor Menshikov 24 Dec 2008 22:50
Test 12: labels after the last command. Like this:

   a = 1
label: