Back
Close
  • 151

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

You are a professional Among Us gamer, however, you don't know who the impostor is! Luckily, you're hacking, so you know the exact path each crewmate took before the EMERGENCY MEETING. You notice that certain crewmates are acting SUSSY - they are moving much faster than they should! You know that there are vents connecting all of the rooms, so there is only 1 possible explanation. Your task is to figure out who is SUS, and vote them out immediately!

The rooms are labelled arranged in cyclic fashion. For example, for a room layout ABCDEF, a crewmate in room D can go to either room C or E, and a crewmate in room A can move to either room B or room F. Changing rooms takes 1 minute.

For each crewmate, you will receive a string of length K. This string is ordered so that the first character represents the position of the crewmate at the first minute, and so on.

Sometimes, the hacks you're using may freeze (because of the bloatware you installed with it), so you will be missing some data. In this case, the character you will be given will be #.

For example, assuming the room layout ABCDEF:
For input ABAFEDEF, the path the crewmate took is A → B → A → F → E → D → E → F. This is not sus, since the crewmate never travels more than 1 room per minute.
For input AFEBAFE, the path the crewmate took is A → F → E → B → A → F → E. This is sus because a normal crewmate cannot travel from room E to room B in 1 minute.
For input B#DCB#F, the path the crewmate took is B → ? → D → C → B → ? → F. This is not sus because the crewmate can travel from B to D in 2 minutes, and B to F in 2 minutes.
Input
Line 1: An integer L representing the length of the room layout.
Line 2: A string F representing the room layout, consisting of L characters.
Line 3: 2 space separated integers, N and K, representing the number of crewmates and the duration of their path recordings in minutes.
Next N lines: A string crewmate representing the path taken by a crewmate. The string consists of K characters, each of which is either an uppercase letter or a number sign (#).
Output
N lines: A string corresponding to each crewmate in the same order as input: SUS if the crewmate is suspicious, or NOT SUS otherwise.
Constraints
6 ≤ L ≤ 26
5 ≤ N ≤ 40
2 ≤ K ≤ 50
All characters in F are uppercase and unique.
It is guaranteed that the letters in crewmate are present in F.
Example
Input
6
ABCDEF
5 3
ABC
AFE
CDC
DBC
AAA
Output
NOT SUS
NOT SUS
NOT SUS
SUS
NOT SUS

A higher resolution is required to access the IDE