Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

Problem hidden on 2013-07-08 19:59:49 by Mitch Schwartz

VPL2_BA - Henus Quest

no tags 


Henu is playing Bookworm, but there are too many words that he doesn’t know, so he created a system to define each word looking up the definition on the Internet, but the Internet is not always accurate and the definitions may have gone wrong, some of them could be invalid definitions. An invalid definition is a word that sooner or later defines itself. By example we have word A, B and C; word A can be defined with word B, word B can be defined with word C, and word C can be defined with word A, in that case, the definition of all A, B and C is invalid. Henu has made his definitions, and he wants to know how many of them are valid.

 

Input

The first line contains an integer T , which specifies the number of test cases. Then, will follow the descriptions of T test cases.

Each test case will start with one integer N , that is the number of words in Henu’s definitions. Then it will be the description of each word, each description is divided in 2 lines, the first line will have a word A and an integer M , the word to define, and the number of words that are used in the definition. Then a line with M words separated by spaces, the words that define A. Each word will have only lowercase characters [a − z] and will have up to 20 characters. All words used to define other words will always be on Henu’s definitions.

 

Output

For each input case you must print a single line with the string Scenario #i: x, where i is the number of the test case (starting at 1), and x is the answer for the problem.

 

 

INPUT

OUTPUT

3

4

ace 2

beast close

close 1

beast

beast 2

prob close

prob 0

5

ace 3

close prob cross

close 1

beast

beast 1

close

prob 1

cross

cross 1

prob

6

ace 1

beast

beast 1

prob

prob 2

cross close

close 1

open

open 1

prob

cross 0

Scenario #1: 2

Scenario #2: 1

Scenario #3: 3

 

Constraints Small - 40%

• 1 ≤ T ≤ 100

• 1 ≤ N ≤ 1000

Constraints Large - 60%

• 1 ≤ T ≤ 100

• 1 ≤ N ≤ 100000 

 


hide comments
Mitch Schwartz: 2013-07-08 17:59:54

I haven't taken the time to implement this and submit, but A appearing in the list after A should definitely be considered invalid according to the problem statement -- the problem is hidden and moved to tutorial waiting for this issue to be addressed. (Please leave a new comment and the problem can be restored.)

Last edit: 2013-07-08 18:09:29
Federico Lebrón: 2013-07-08 17:29:40

OK, got AC.

The test data is incorrect for test cases #0 and #4. They contain definitions of the form "A is defined using A", and A is considered _valid_. This is incorrect, as A "sooner or later defines itself", and should be considered _invalid_. Test data should be fixed, and solutions rejudged.

mehmetin: 2013-07-08 16:51:31

Yes, the interpretation is correct. Thanks. I had misunderstood. AC now.

Miguel Oliveira: 2013-07-08 16:44:11

I have the same interpretation as Federico. The problem seems simple but I also have WA (tests 1 and 3).
edit: i had some bug, spoiler removed

Last edit: 2013-07-08 17:17:37
Federico Lebrón: 2013-07-08 16:16:16

From what I read, if D has no definition (and these are all lowercase, of course), then {A, B, C} are invalid, and {D} is valid.

mehmetin: 2013-07-08 15:22:03

Consider this example:
A->B
B->C
C->A
C->D

A,B,C are all valid?

Last edit: 2013-07-08 16:12:58
Federico Lebrón: 2013-07-08 02:34:04

Are test cases 0 and 4 correct?

If so, is it correct to say a word with no definition (i.e. M = 0) is valid, and a word that uses itself in its immediate definition (i.e. A appears in the line after A) is invalid?


Added by:Venezuelan Programming League
Date:2013-06-29
Time limit:3s-8s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64