pdxbshx 2022-04-21 01:09 采纳率: 100%
浏览 43
已结题

PTA天梯赛练习题-帅到没朋友,求指出问题所在


n = int(input())
list1 = []
list2 = []
list3 = []
for i in range(n):
    s = str(input())
    if s[0] == '1':
        list2.append(int(s[2:7]))
        continue
    elif s[0] == '0':
        continue
    else:
        for j in range(int(s[0])):
            list1.append(int(s[(2+6*j):(7+6*j)]))
list1 = list(set(list1))
m = int(input())
s1 = str(input())
for i in range(m):
    list2.append(int(s1[(0+i*6):(5+6*i)]))
for i in range(len(list2)):
    for j in range(len(list1)):
        if list2[i] == list1[j]:
            list3.append(list2[i])
list = list(set(list2)-set(list3))
if list == []:
    print('No one is handsome')
else:
    for i in range(len(list)):
        if i == len(list)-1:
            print(list[i])
        else:
            print(list[i],end=' ')

上面就是我写的代码,实在想不出问题所在

  • 写回答

1条回答 默认 最新

  • A Python 萌新花花 2022-04-21 08:19
    关注
    
    a = int(input())
    empty1 = []
    handsome = []
    getid = []
    
    check = []
    amount = 0
    for i in range(a):
        b = input().split(" ")
        b = list(map(lambda x: int(x),b))
        if b[0] == 1:
            handsome.append(b[1])
        getid += b[1:]
        print(getid)
    
    c = int(input())
    d = input().split(" ")
    d = list(map(lambda x: int(x),d))
    
    for i in d:
        if i not in getid:
            handsome.append(i)
    
    real = sorted(set(handsome),key=handsome.index)
    if len(handsome) == 0:
        print("No one is handsome")
    else:
        print(*real)
    

    给你简化了一下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月29日
  • 已采纳回答 4月21日
  • 创建了问题 4月21日

悬赏问题

  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线