|
|
вернуться в форумI hate the time limit l1=[] l2=[] l3=[] for i in range(0,1000): l3.append(False) def funct(a): b=a.split() if b[0]=='register': if b[1] not in l1: l1.append(b[1]) l2.append(b[2]) print("success: new user added") else: print("fail: user already exists") elif b[0]=="login": if b[1] not in l1: print("fail: no such user") else: k=l1.index(b[1]) if l3[k]: print("fail: already logged in") else: if l2[k]==b[2]: l3[k]=True print("success: user logged in") else: print("fail: incorrect password") elif b[0]=="logout": k=l1.index(b[1]) if l3[k]: l3[k]=False print("success: user logged out") else: print("fail: already logged out") f=int(input()) for m in range(0,f): n=input() funct(n) f**king time limit!!! Re: I hate the time limit List is O(n) lookup, while dict is O(log n), so use that |
|
|