65分,求助
查看原帖
65分,求助
1248152
cdAGcwhml楼主2024/8/30 10:52
class sr:
    def __init__(self):
        self._id=[-1,-1,-1,-1,-1]
        self.idx=0
    def ck(self,id_):
        global se
        if id_.count(".")==3 and id_.count(":")==1 and len(id_)-1-list(reversed(id_)).index(".")<id_.index(":"):
            self._id[0],self._id[1],self._id[2],self._id[3]=id_.split(".")
            self._id[3],self._id[4]=self._id[3].split(":")
            if len(list(filter(lambda x:int(x)<=255 and not (x!="0" and x[0]=="0"),self._id[0:4:1])))==4 and int(self._id[-1])<=65535:
                for i in se:
                    if self._id==i._id:
                       return "FAIL"
                se.append(self)
                return "OK"
            else:
                return "ERR"
        else:
            return "ERR"
def js(id_):
        global se
        _id=[-1,-1,-1,-1,-1]
        if id_.count(".")==3 and id_.count(":")==1 and len(id_)-1-list(reversed(id_)).index(".")<id_.index(":"):
            _id[0],_id[1],_id[2],_id[3]=id_.split(".")
            _id[3],_id[4]=_id[3].split(":")
            if len(list(filter(lambda x:int(x)<=255 and not (x!="0" and x[0]=="0"),_id[0:4:1])))==4 and int(_id[-1])<=65535:
                for i in se:
                    if _id==i._id:
                        for i in se:
                            if i._id==_id:
                                return i.idx
                return "FAIL"
            else:
                return "ERR"
        else:
            return "ERR"    
n=int(input())
se=[]
for i in range(n):
    a=0
    s,t=input().split()
    if s=="Server":
        a=sr()
        a.idx=i+1
        print(a.ck(t))
    else:
        print(js(t))

2024/8/30 10:52
加载中...