QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#321553#4825. Even and Odd Combinationstuanlinh1230 1ms3780kbC++201.6kb2024-02-04 22:34:372024-02-04 22:34:38

Judging History

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

  • [2024-02-04 22:34:38]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3780kb
  • [2024-02-04 22:34:37]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;

ll C[55][55];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    for (ll i=0; i<=50; i++)
        for (ll j=i; j<=50; j++)
        {
            if (i==j || i==0) C[i][j]=1;
            else C[i][j]=C[i][j-1]+C[i-1][j-1];
        }
    ll t; cin >> t;
    while (t--)
    {
        ll n, k; cin >> n >> k;
        auto state_to_num=[&](vector <ll> a)
        {
            ll m=a.size(), ans=1;
            for (ll i=m-2; i>=0; i-=2)
                ans+=C[i][n];
            for (ll i=1, ptr=0; i<=n; i++)
            {
                while (ptr<a.size() && a[ptr]==i) ptr++, i++;
                if (ptr==a.size()) break;
                ans+=C[m-ptr-1][n-i];
            }   
            return ans;
        };
        auto num_to_state=[&](ll k, ll parity)
        {
            vector <ll> ans;
            for (ll m=parity, val=0; val<k; val+=C[m][n], m+=2)
                if (val+C[m][n]>=k) for (ll i=1, num=m; i<=n && num<=m; i++)
                {
                    if (val+C[num-1][n-i]>=k) ans.pb(i), num--;
                    else val+=C[num-1][n-i];
                }
            return ans;
        };
        vector <ll> a(k);
        for (ll i=0; i<k; i++) cin >> a[i];
        ll s=state_to_num(a);
        a=num_to_state(s, (k+1)%2);
        cout << n << " " << a.size() << "\n";
        for (ll i:a) cout << i << " "; cout << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3776kb

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:

3 0

2 1
1 
3 3
1 2 3 
3 1
1 
3 1
2 
3 1
3 

result:

ok 12 lines

Test #2:

score: 100
Accepted
time: 0ms
memory: 3780kb

input:

1
1 0

output:

1 1
1 

input:

1
1 1
1

output:

1 0


result:

ok single line: '1 0'

Test #3:

score: 100
Accepted
time: 1ms
memory: 3780kb

input:

3
1 1
1
1 0
1 1
1

output:

1 0

1 1
1 
1 0


input:

3
1 0
1 1
1
1 0

output:

1 1
1 
1 0

1 1
1 

result:

ok 6 lines

Test #4:

score: 0
Wrong Answer on the first run

input:

1000
12 7
1 2 3 5 6 7 9
11 6
3 5 6 7 8 11
12 7
1 6 7 9 10 11 12
11 6
1 2 3 9 10 11
12 7
2 3 4 6 7 9 10
9 3
3 7 8
12 10
1 2 3 5 7 8 9 10 11 12
12 5
2 6 10 11 12
10 4
2 4 8 10
12 7
1 3 4 7 10 11 12
11 3
3 6 7
11 6
3 5 7 8 9 10
12 5
1 4 8 11 12
11 6
2 3 5 6 9 10
12 5
2 4 7 11 12
12 6
3 4 5 6 10 12
10 6...

output:

12 6
2 3 5 6 7 9 
11 7
1 3 5 6 7 8 11 
12 6
6 7 9 10 11 12 
11 5
2 3 9 10 11 
12 8
1 2 3 4 6 7 9 10 
9 4
1 3 7 8 
12 9
2 3 5 7 8 9 10 11 12 
12 6
1 2 6 10 11 12 
10 5
1 2 4 8 10 
12 6
3 4 7 10 11 12 
11 4
1 3 6 7 
11 7
1 3 5 7 8 9 10 
12 4
4 8 11 12 
11 7
1 2 3 5 6 9 10 
12 6
1 2 4 7 11 12 
12 7
1 3...

input:


output:


result:

wrong answer the size of your subset must have a different parity (test case 577)