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

Burunduk1 Test 12. Is it correct? [6] // Problem 1438. Time Limit Exceeded 4 Jun 2006 22:15
There are two labels in one string!
Dmitry 'Diman_YES' Kovalioff I tried to prove it but failed (+) [4] // Problem 1438. Time Limit Exceeded 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.
Burunduk1 Re: I tried to prove it but failed (+) [3] // Problem 1438. Time Limit Exceeded 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
Vladimir Yakovlev (USU) Re: I tried to prove it but failed (+) [1] // Problem 1438. Time Limit Exceeded 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.
Thank you :)

PS: I repeat this bug again and again :(
Ivankov Dmitry Re: I tried to prove it but failed (+) // Problem 1438. Time Limit Exceeded 4 Jun 2006 23:48
"S += len" is wrong ;)
Fyodor Menshikov Re: Test 12. Is it correct? // Problem 1438. Time Limit Exceeded 24 Dec 2008 22:50
Test 12: labels after the last command. Like this:

   a = 1
label: