#39414: WA (line:8939) python


yun0516_0326 (y)

學校 : 不指定學校
編號 : 251767
來源 : [114.36.96.221]
最後登入時間 :
2024-02-17 11:33:05
a291. nAnB problem | From: [114.36.96.221] | 發表日期 : 2024-02-17 11:54

#0: 100% WA (line:8939)

您的答案為: 0A3B
正確答案為: 0A2B

from sys import stdin
output = ''  #將資料結束後一次輸出減少耗時
for s in stdin:
    if s.strip() == '': continue
    pwd = s.split()
    d={'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0,'0':0}
    for p in pwd:
            d[p]+=1
    for _ in range(int(stdin.readline())):  #讀取數字行
        test=stdin.readline().split()
        ans=pwd.copy()     #複製pwd給ans,兩者為不同對象
        dis=d.copy()
        ACount=0
        BCount=0
        for i in range(len(ans)):
            if ans[i]==test[i]:
                dis[ans[i]]-=1
                ACount+=1
                ans[i]='check'
                test[i]='check'
        for a in ans:
            if a in test and a!='check' and dis[a]>0:
                dis[a]-=1
                BCount+=1
        output+=f'{ACount}A{BCount}B\n'
print(output)
 
求各位大佬幫看一下
 
ZeroJudge Forum