#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[20];
int main(){
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++)
a[i] = i;
int cnt = 0;
do{
int p = 1;
for (int i = 2; i <= n; i++)
p += (a[i] < a[i - 1]);
cnt += (p == k);
}while (next_permutation(a + 1, a + n + 1));
cout << cnt << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
41 ms |
384 KB |
Output is correct |
3 |
Correct |
42 ms |
384 KB |
Output is correct |
4 |
Correct |
42 ms |
384 KB |
Output is correct |
5 |
Correct |
42 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
41 ms |
384 KB |
Output is correct |
3 |
Correct |
42 ms |
384 KB |
Output is correct |
4 |
Correct |
42 ms |
384 KB |
Output is correct |
5 |
Correct |
42 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Execution timed out |
1077 ms |
384 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
41 ms |
384 KB |
Output is correct |
3 |
Correct |
42 ms |
384 KB |
Output is correct |
4 |
Correct |
42 ms |
384 KB |
Output is correct |
5 |
Correct |
42 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Execution timed out |
1077 ms |
384 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
41 ms |
384 KB |
Output is correct |
3 |
Correct |
42 ms |
384 KB |
Output is correct |
4 |
Correct |
42 ms |
384 KB |
Output is correct |
5 |
Correct |
42 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Execution timed out |
1077 ms |
384 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |