QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#262820#5161. Last GuessbcwdCompile Error//C++141.4kb2023-11-24 07:21:562023-11-24 07:21:58

Judging History

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

  • [2023-11-24 07:21:58]
  • 评测
  • [2023-11-24 07:21:56]
  • 提交

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

answer.code:1:1: error: ‘g’ does not name a type
    1 | g, x = [int(i) for i in input().split(" ")]
      | ^
answer.code:6:1: error: ‘alpha’ does not name a type
    6 | alpha = "abcdefghijklmnopqrstuvwxyz"
      | ^~~~~
answer.code:16:5: error: expected unqualified-id before ‘for’
   16 |     for i in range(len(l)):
      |     ^~~