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 1880. Psych Up's Eigenvalues

Help me (Python)
Posted by ArtemNazarov 31 Oct 2017 12:06
Time limit. Where is my mistake?
cnt1 = int(input())
lst1 = input()
lst1 = lst1.split()
cnt2 = int(input())
lst2 = input()
lst2 = lst2.split()
cnt3 = int(input())
lst3 = input()
lst3 = lst3.split()
cnt = 0
for i in range(cnt1):
    for j in range(cnt2):
        if lst1[i] == lst2[j]:
             for k in range(cnt3):
                    if lst1[i] == lst3[k]:
                        cnt += 1
        else:
             continue
print(cnt)

Edited by author 31.10.2017 14:42
Re: Help me (Python)
Posted by misha 31 May 2018 14:24
Your code has O(cnt1 * cnt2 * cn3). If cnt1 is 4000, cnt2 is 4000, cnt3 is 4000, Your code will work (4000*4000*4000)/10^8 seconds. 640 seconds. 640 > 0.5
Re: Help me (Python)
Posted by ViktorL 15 Jul 2018 02:41
I agree 640>0.5


Edited by author 15.07.2018 02:43

Edited by author 15.07.2018 02:43
Ac
Posted by eremeev.me.2012@gmail.com 7 Oct 2023 11:27
a = input()
A = list(map(int , input().split()))
a = input()
B = list(map(int , input().split()))
a = input()
C = list(map(int , input().split()))
print(len(set(A) & set(B) & set(C)))