RPLG - Goto & labels

Vero is working on an important company, the company noticed that Vero codes using goto labels, her boss does not want Vero to code this kind of programs, the boss tells her that he will cut her payment by the number of lines contained between the label and the goto.

 

Vero does not know any iterative structures, and she is too worried to code the program she is asking you for, Code a solution for Vero's problem.

 

The solution to this is to count the lines of code that are between the label and the goto statement, having in consideration that the goto will always return to an existent label, the label will consist on a single string formed by letters from the 'a' to the 'z' and from the 'A' to the 'Z', all labels will have the format as the goto will always contains the format goto , however, remember that before the labels and the gotos you can have an important amount of spaces that will count as an indentation of a code.

Note: An uppercase letter label is distinct from a lowercase letter label, by example: 'abc' is not equal to 'ABC'

 

INPUT:

The first line of input will contain an integer T denoting the T test cases, then, T cases will follow. Each of the following line will contain an integer N, then, N lines will follow, each of the next N lines will contain a string S.

 

OUTPUT:

Output the string “Scenario #i: “ where i is the test case you are analyzing followed by the sum of the number of lines between the label and the goto.

 

SAMPLE DATA:

 

INPUT

OUTPUT

3

6

A:

      SPACES will InDeNt the CoDe

      No TaBs ArE iN the >> test << data

goto A;

B:

goto B;

7

B:

A:

cin >> n;

    if(n<0) then

       goto A;

    else

       goto B;

7

       A:

         TumbaBicho:

           printf("goto TumbaBicho");

       printf("goto TumbaBicho");

     goto TumbaBicho;

AA:

           goto A;

Scenario #1: 2

Scenario #2: 7

Scenario #3: 7

 

CONSTRAINTS:

1<=N<=10000

1<= Length of string <= 1000


Added by:david_8k
Date:2012-05-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem used for the RPL contest

hide comments
2014-01-23 17:07:22 Piyush Raman Srivastava
Thanks to the constraints clarification by @:D !!

Last edit: 2014-01-23 17:22:54
2012-07-23 23:38:38 Brian Curcio
My bad, didn't read there could be multiple goto's for same label

Last edit: 2012-07-23 23:54:24
2012-07-14 07:24:57 Zhouxing Shi
I've just understand the problem!
2012-05-26 19:58:30 Srijan Kumar
Are these assumptions ok:
A label occurs before its corresponding gotos occur
and
there are no empty(blank) lines in the inputs

Also, in the problem statement, it is said that the gotos are of the form goto
2012-05-26 19:58:30 Samuel Nacache
One of my favorite problems =D
Felix dice: jalabolas.

Last edit: 2012-06-30 02:31:19
2012-05-26 19:58:30 david_8k
Your program must support multiple jumps, however, there will be no labels with the same name and the goto will contain any existíng label from 0 to n-1, being n the line of the goto... Hope this helps
2012-05-26 19:58:30 :D
As I understand the description, there is no such guarantee. You should implement multiple jumps.

More importantly the goto and label "commands" must not be followed by any code in the same line! Please clarify in the description that there can be nothing more in the given lines.
2012-05-26 19:58:30 Saurabh Jain
nice problem !!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.