HCI '16 - Poké Problem

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 64M

Authors:
Problem type

Due to the recent Pokémon games that came out, Sun and Moon, we might as well create a problem based on it.

Given the effectiveness of certain types over another, and the typing of the Pokémon, determine which type would be the most effective against the Pokémon.

Input Specification

The first line of input includes 2 integers, N, the number of types, and C.

The next C lines show you which types are effective against which, as denoted by integers A and B, where "A is super effective against B" and as such "B is not effective against A". (As a side note, the types are depicted through numbers 1 to N, and if a type is not explicitly shown to be super or not effective against another type, it's considered neutral).

The next line shows you the number of types the Pokémon has.

The following line shows the type(s) of that Pokémon (a Pokémon can only have either one or two types).

Output Specification

The output will consist of one number which is the type that the Pokémon is weakest against.

Please note the following:

  • A type that is super effective against both of the Pokémon's types is better than a type that is super effective against only one of the types.
  • If a type is super effective against one of the types of the Pokémon, but is not effective against the other, it is considered neutral.
  • If none of the types are super effective against the Pokémon (That is, all the types are not effective or do neutral damage to the Pokémon), then output 0.
  • If one type has the same effectiveness against the Pokémon as another type, output the smaller/smallest number.

Constraints

Subtask 1 [100%]

2 \le N \le 100

1 \le C \le 100

Subtask 2 [0%]

Sample test cases.

Sample Input 1

4 3
1 2
2 3
3 4
2
3 4

Sample Output 1

2

Sample Input 2

3 2
2 1
3 2
2
1 3

Sample Output 2

0

Comments

There are no comments at the moment.