#K36397. Find Scenes with a Character

    ID: 25745 Type: Default 1000ms 256MiB

Find Scenes with a Character

Find Scenes with a Character

You are given a target character's name and a list of scenes. Each scene is a string consisting of space-separated names of characters present in that scene. Your task is to find all the scene numbers (1-indexed) where the target character appears. If the target character does not appear in any scene, output "Not found".

For example, if the input is:

JonSnow 5 AryaSansa Ned JonSnow Tyrion JonSnow Robb Daenerys Cersei Samwell Gilly JonSnow Jorah

then the output should be:

1 2 4

Note: The output scene numbers should be printed on a single line separated by spaces.

inputFormat

The input is given via standard input and consists of multiple lines:

  1. The first line contains a string representing the target character's name.
  2. The second line contains an integer (n) representing the number of scenes.
  3. The following (n) lines each contain a scene description, which is a space-separated string of character names.

outputFormat

Print to standard output:

  • If the target character appears in one or more scenes, output the scene numbers (1-indexed) separated by a single space on one line.
  • If the target character does not appear in any scene, output exactly "Not found".## sample
JonSnow
5
AryaSansa Ned JonSnow
Tyrion JonSnow Robb
Daenerys Cersei
Samwell Gilly JonSnow
Jorah
1 2 4