Someone‘s Acting Sus....

本文介绍了一个游戏情境中,作为专业玩家如何通过分析队友的移动路径,识别在紧急会议前行动异常(SUS)的成员。通过房间布局和时间限制,你需要找出那些移动速度过快的可疑人员并投票排除他们。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 (examples with room layout ABCDEF:
For input ABAFEDEF, the path the crewmate took is <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 <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 <?->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

An integer, L.
A line F of length L, corresponding to the room layout. All characters in F will be uppercase and unique.
2 space separated integers, N and K, representing the number of crewmates and the length of time the crewmates were recorded (length of each string).
This is followed by N strings, comprised of capital letters, or number signs (#), each of length K. It is guaranteed that the letters will be present in line F.


Output

N lines corresponding to each of the N crewmates. Output “SUS” if the crewmate is suspicious, otherwise print “NOT SUS”.


Constraints

6<=L<=26
5<=N<=40
2<=K<=50


Example

Input
6
ABCDEF
5 3
ABC
AFE
CDC
DBC
AAA


Output
NOT SUS
NOT SUS
NOT SUS
SUS
NOT SUS

解决思路(没有优化,不能通过大数据验证):

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

class MapNode():
    def __init__(self, id:str):
        self.id = id
        self.left = None
        self.right = None

l = int(input())
f = input()

map = {}

for i in f:
    map[i] = MapNode(i)

for i in range(l):
    ltmp = i-1
    rtmp = i+1
    if ltmp < 0:
        ltmp = l-1
    if rtmp == l:
        rtmp = 0
    map[f[i]].left = map[f[ltmp]]
    map[f[i]].right = map[f[rtmp]]

def minRouteLength(route, end_point:str, route_length = 0):
    # print(str(route.id) + ' ' + str(end_point), file=sys.stderr, flush=True)
    if route.id == end_point or not route.left or not route.right or route_length >= l+l:
        # print('exit func ' + str(route_length), file=sys.stderr, flush=True)
        return route_length
    left = minRouteLength(route.left, end_point, route_length+1)
    return min(minRouteLength(route.right, end_point, route_length+1), left)

n, k = [int(i) for i in input().split()]
for i in range(n):
    crewmate = input()
    
    length = len(crewmate)
    start = 0
    for j in range(length):
        if crewmate[j] != '#':
            route = map[crewmate[j]]
            start = j+1
            break
    else:
        print('NOT SUS')
        continue
    bad_cnt = 0
    for j in range(start, length):
        if crewmate[j] == '#':
            bad_cnt += 1
            continue
        minrl = minRouteLength(route, crewmate[j])
        # print('min ' + str(minrl) + ' ' + str(bad_cnt+1), file=sys.stderr, flush=True)
        if minrl > 1 and bad_cnt == 0 or minrl > bad_cnt+1:
            print('SUS')
            break
        route = map[crewmate[j]]
        bad_cnt = 0
    else:
        print('NOT SUS')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值