其他分享
首页 > 其他分享> > 2022 8 25

2022 8 25

作者:互联网

只做了一个组队题目https://www.lanqiao.cn/problems/604/learning/

报错是因为s1,s2里面的内容被更改,于是超出列表范围了。

具体的周末整理的时候再说。

import os
import sys

s1 = [97, 92, 0, 0, 89, 82, 0, 0, 0, 95, 0, 0, 94, 0, 0, 0, 98, 93, 0, 0]
s2 = [90, 90, 85, 0, 0, 83, 86, 0, 97, 0, 99, 0, 0, 91, 83, 0, 0, 83, 87, 0, 99]
s3 = [0, 96, 0, 0, 97, 0, 0, 96, 89, 0, 96, 0, 0, 87, 98, 0, 99, 92, 0, 96]
s4 = [0, 0, 0, 80, 0, 0, 87, 0, 0, 0, 97, 93, 0, 0, 97, 93, 98, 96, 89, 95]
s5 = [0, 0, 93, 86, 0, 0, 90, 0, 0, 0, 0, 98, 0, 0, 98, 86, 81, 98, 92, 81]
s = [s1, s2, s3, s4, s5]

t_s = []
index = 0

for i in range(5):
    copyS = s.copy()[i]
    for j in range(5):
        index = copyS.index(max(copyS))
        t_s.append(index)
        copyS.remove(copyS[index])
print(t_s)

temp = 0

# lis=[[] for i in range(5)]
# print(lis)
# for i in range(0,1):
#     for j in range(0,1):
#         lis[i][j]=t_s[i*5+j+1]
# print(lis)

result = []

for y in range(0, 5):  # 控制行
    for x in range(0, 5): # 控制列
        if x == 0:
            result.append([])
        result[y].append(t_s[x + y * 5])  # 这里的3是由控制列长度决定。是为了使结果按原顺序变形,避免混乱。
print(result)

anchor = [0] * 5
best = 0
sth = 0
finalName = []

s1 = [97, 92, 0, 0, 89, 82, 0, 0, 0, 95, 0, 0, 94, 0, 0, 0, 98, 93, 0, 0]
s2 = [90, 90, 85, 0, 0, 83, 86, 0, 97, 0, 99, 0, 0, 91, 83, 0, 0, 83, 87, 0, 99]
s3 = [0, 96, 0, 0, 97, 0, 0, 96, 89, 0, 96, 0, 0, 87, 98, 0, 99, 92, 0, 96]
s4 = [0, 0, 0, 80, 0, 0, 87, 0, 0, 0, 97, 93, 0, 0, 97, 93, 98, 96, 89, 95]
s5 = [0, 0, 93, 86, 0, 0, 90, 0, 0, 0, 0, 98, 0, 0, 98, 86, 81, 98, 92, 81]

for i in result[0]:
    finalName.append(i)
    for j in result[1]:
        if(j in finalName):
            continue
        finalName.append(j)
        for k in result[2]:
            if(k in finalName):
                continue
            finalName.append(k)
            for l in result[3]:
                if(l in finalName):
                    continue
                finalName.append(l)
                for m in result[4]:
                    if(m in finalName):
                        continue
                    sth = s1[i]+s2[j]+s3[k]+s4[l]+s5[m]
                    if(sth>best):
                        best = sth
                finalName.remove(l)
            finalName.remove(k)
        finalName.remove(j)
    finalName.remove(i)
print(best)

 

标签:25,finalName,98,result,2022,93,97,96
来源: https://www.cnblogs.com/MrMKG/p/16626234.html