QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#262821#5161. Last GuessbcwdRE 0ms0kbPython31.4kb2023-11-24 07:23:082023-11-24 07:23:08

Judging History

你现在查看的是最新测评结果

  • [2023-11-24 07:23:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-24 07:23:08]
  • 提交

answer

g, x = [int(i) for i in input().split(" ")]

ans = ["" for i in range(x)]

use = {}
alpha = "abcdefghijklmnopqrstuvwxyz"
fillers = list(alpha)

for i in range(g-1):
    string, output = input().split(" ")
    l = list(output)
    s = list(string)

    temp = {}

    for i in range(len(l)):
        if l[i] == "G":
            ans[i] = s[i]
            if s[i] in temp.keys():
                temp[s[i]] += 1
            else:
                temp[s[i]] = 1
        elif l[i] == "Y":
            if s[i] in use.keys():
                use[s[i]][1].append(i)
            else:
                use[s[i]] = [0, []]
                use[s[i]][1].append(i)
            if s[i] in temp.keys():
                temp[s[i]] += 1
            else:
                temp[s[i]] = 1
        else:
            if s[i] in fillers:
                fillers.remove(s[i])
        
    for j in temp.keys():
        if j in use.keys():
            if temp[j] > use[j][0]:
                use[j][0] = temp[j]
        else:
            use[j] = [0, []]
            use[j][0] = temp[j]

for i in use:
    if use[i][0] != ans.count(i):
        for k in range(x):
            if (ans[k] == "") and (k not in use[i][1]):
                ans[k] = i
                use[i][0] -= 1

if "" in ans:
    for z in range(x):
        if (ans[z] == ""):
            ans[z] = fillers[0]

print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Checker Runtime Error

input:

4 5
reply YYGBB
refer BBBGG
puppy YYGBB

output:

['u', 'p', 'p', 'e', 'r']

result: