#45708: TLE(3s) 想知道哪裡可以優化


aztec960523@gmail.com (王品翔)

學校 : 不指定學校
編號 : 238174
來源 : [180.177.32.32]
最後登入時間 :
2025-04-06 20:42:41
a291. nAnB problem | From: [180.177.32.32] | 發表日期 : 2025-04-03 15:22

while True:
    try:                
        first_inp = input()
        if first_inp == "":
            continue
       
        ans = list(first_inp.split(" "))
        n = int(input())

        for i in range(n):
            p = q = 0
            test = list(input().split(" "))
            for j in range(4):
                if test[j] == ans[j]:
                    test[j] = -1
                    p += 1
                    continue
               
                for k in range(4):
                    if test[k] == ans[j]:
                        q += 1
                        break      
            print("{}A{}B".format(p, q))

    except:
        break
 
ZeroJudge Forum