QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#262821 | #5161. Last Guess | bcwd | RE | 0ms | 0kb | Python3 | 1.4kb | 2023-11-24 07:23:08 | 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)
详细
Test #1:
score: 0
Checker Runtime Error
input:
4 5 reply YYGBB refer BBBGG puppy YYGBB
output:
['u', 'p', 'p', 'e', 'r']