以下附上我的程式碼
-------------------------------------------
n, m = map(int, input().split())
for i in range(n):
sum = 0
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for j in range(m):
for k in range(m):
if a[j] == b[k]:
sum += 1
break
print(sum)
-------------------------------------------
感謝各位大佬指點 !!!
for j in range(m):
for k in range(m):
if a[j] == b[k]:
sum += 1
break
數字是遞增的,所以一層迴圈就夠了,可以參考解題報告