关于D题Python
  • 板块学术版
  • 楼主zzash
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/12/31 18:31
  • 上次更新2023/12/31 22:09:14
查看原帖
关于D题Python
1227324
zzash楼主2023/12/31 18:31

为什么我的代码AC UKE TLE全有

t=int(input())
times=0
def mex(m,a):
    global times
    mex_mex=[]
    for i in a:
        temp_a = a.copy()
        del temp_a[a.index(i)]
        small=min(temp_a)
        if 0 not in temp_a or temp_a.count(0)==len(temp_a):
            small=0
        else:
            while small in temp_a:
                small+=1
        mex_mex.append(small)
    times+=1
    if times>=m:
        return mex_mex
    else:
        mex_mex=mex(m,mex_mex)
        return mex_mex
for i in range(t):
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mex_mex=mex(m,a)
    for c in mex_mex:
        print(c,end=" ")
    print("\n",end="")
2023/12/31 18:31
加载中...