define _CRT_SECURE_NO_WARNI NGS include iostream include vector includ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
long long dp[20][210];
vector <bool> num;
int main() {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n, t;
cin >>n >>t;
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 0; j <= t; ++j) {
for (int k = 0; k < i; ++k) {
dp[i][j + k] += dp[i - 1][j];
}
}
}
cout <<dp[n][t] <<endl;
num.assign(n, false);
if (dp[n][t] == 0) {
cout <<'-'<<endl;
return 0;
}
for (int i = 0; i < n; ++i) {
int count = 0;
for (int j = 0; j < n; ++j) {
if (!num[j]) {
if ((n - i - 1) * (n - i - 2) / 2 + count >= t) {
num[j] = true;
cout <<j + 1 <<' ';
break;
} else {
count++;
}
}
}
t -= count;
}
return 0;
}