ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2002. Test Task

I hate the time limit
Posted by Savchuk Nickolay 12 Jun 2021 16:22
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
Posted by qumusabel 14 Jul 2021 17:34
List is O(n) lookup, while dict is O(log n), so use that