#41375: python


suyueh (suyueh)

學校 : 不指定學校
編號 : 272111
來源 : [101.12.162.212]
最後登入時間 :
2024-11-10 22:20:41
a291. nAnB problem | From: [125.229.229.84] | 發表日期 : 2024-07-22 13:54

from sys import stdin
output = ''        
for s in stdin:    
  if s.strip() == '': continue  
  pwd = s.split()  
  dic = {str(k):0 for k in range(10)}  
  for i in pwd: dic[i] += 1    
  n = int(stdin.readline())    
  for _ in range(n):        
    ans = stdin.readline().split()  
    a, b, c, d = 0, 0, pwd[:], dic.copy()
   
    for j in range(4):
      if ans[j] == pwd[j]:    
        d[str(pwd[j])] -= 1  
        a = a + 1            
        c[j] = 'o1'          
        ans[j] = 'o2'        
    for j in ans:
      if j in c and d[j]>0:  
        d[j] -= 1              
        b = b + 1            
    output = output + f'{a}A{b}B\n'
print(output)
 
ZeroJudge Forum