QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#295342#4825. Even and Odd Combinationsucup-team1766#0 0ms0kbC++231.1kb2023-12-31 03:07:332023-12-31 03:07:34

Judging History

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

  • [2023-12-31 03:07:34]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-12-31 03:07:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int C[50 + 1][50 + 1];

void run() {
        int n, k; cin >> n >> k;

        long long ind = 0;
        for (int i = k%2; i < k; i+=2) {
                // n choose i
                ind += C[n][i];
        }
        for (int i = 1; i <= k; i++) {
                int a; cin >> a;
                ind += 1ll * (a-i) * C[n-i][k-i];
        }

        int nk = 1-k%2;
        for (int i = 1-k%2; ind >= C[n][i]; i+=2) {
                ind -= C[n][i];
                nk += 2;
        }
        cout << n << ' ' << nk << '\n';
        for (int i = 1,last=0; i <= nk; i++) {
                int a = ind / C[n-i][nk-i];
                ind -= a*C[n-i][nk-i];
                last += a + 1;
                cout << last << ' ';
        }
        cout << '\n';
        assert(!ind);
}

int main() {
        cin.tie(0)->sync_with_stdio(0);
        C[0][0] = 1;
        for (int n = 1; n <= 50; ++n) {
            C[n][0] = C[n][n] = 1;
            for (int k = 1; k < n; ++k)
                C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
        }
        int t; cin >> t; while (t--) run();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Stage 2: 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:

3 1
1 
2 0

3 2
2 3 
3 0

3 2
1 2 
3 2
1 3 

input:

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

output:


result: