QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749787#4825. Even and Odd Combinationssupepapupu0 0ms0kbPython31.2kb2024-11-15 10:14:242024-11-15 10:14:25

Judging History

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

  • [2024-11-15 10:14:25]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-11-15 10:14:24]
  • 提交

answer

fac = [1 for i in range(51)]
for i in range(1, 51): fac[i] = fac[i] * fac[i - 1]
def binom(a, b):
    if b < 0: return 0
    return fac[a] // fac[b] // fac[a - b]

def solve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    if n & 1:
        print(n, n - k)
        b = []
        for i in range(1, n + 1):
            if not i in a:
                b.append(i)
        print(" ".join(list(map(str, b))))
        return

    tot = 0
    for i in range(k & 1, k, 2):
        tot += binom(n, i)
    
    cnt = 0
    for i in range(1, n + 1):
        if i in a:
            cnt += 1
        else:
            tot += binom(n - i, k - cnt - 1)

    for i in range(~k & 1, n + 1, 2):
        if tot > binom(n, i):
            tot -= binom(n, i)
            continue
        cnt = 0
        b = []
        for j in range(1, n + 1):
            if tot > binom(n - j, i - cnt - 1):
                tot -= binom(n - j, i - cnt - 1)
                continue
            b.append(j)
            cnt += 1
        break
    print(n, len(b))
    print(" ".join(list(map(str, b))))    

T = int(input())
for _ in range(T):
    solve()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Stage 1: Program answer Runtime Error

input:

6
3 0
2 1
1
3 3
1 2 3
3 1
1
3 1
2
3 1
3

output:


input:


output:


result: