本地没问题,全RE

P2249 【深基13.例1】查找

a15801016376 @ 2024-12-09 21:20:28

本人较懒,用Python字典去做,本地正常,提交全RE怎么回事

class ResearchList:
    def __init__(self,Lens,ResearchNum):
        self.List = []
        self.MaxListLen = Lens
        self.ResearchNum = ResearchNum
        self.NeedList = []
        self.DictList = {}

    def Input(self):
        self.List = list(map(int,input().split()))
        self.NeedList = list(map(int,input().split()))

    def Dict(self):
        id = 1
        for i in self.List:
            if i in self.DictList:
                continue
            else:
                self.DictList[i] = id
                id += 1

    def Research(self):
        for i in self.NeedList:
            if i in self.DictList:
                print(self.DictList[i],end=' ')
            else:
                print(-1,end=' ')

def main():
    n,m = map(int,input().split())
    list = ResearchList(n,m)
    list.Input()
    list.Dict()
    list.Research()

if __name__ == '__main__':
    main()

|