// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int perm[15];
int n, k;
void solve() {
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; ++i) {
perm[i] = i;
}
int ans = 0;
do {
int a = 1, b = 0;
for (int i = 1; i <= n; ++i) {
if (perm[i] < b) {
++a;
}
b = perm[i];
}
if (a == k) {
++ans;
}
}
while (next_permutation(perm + 1, perm + n + 1));
printf("%d\n", ans);
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message
asceticism.cpp: In function 'void solve()':
asceticism.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &k);
~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
67 ms |
376 KB |
Output is correct |
3 |
Correct |
67 ms |
356 KB |
Output is correct |
4 |
Correct |
67 ms |
256 KB |
Output is correct |
5 |
Correct |
66 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
8 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
67 ms |
376 KB |
Output is correct |
3 |
Correct |
67 ms |
356 KB |
Output is correct |
4 |
Correct |
67 ms |
256 KB |
Output is correct |
5 |
Correct |
66 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
8 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
1079 ms |
256 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
67 ms |
376 KB |
Output is correct |
3 |
Correct |
67 ms |
356 KB |
Output is correct |
4 |
Correct |
67 ms |
256 KB |
Output is correct |
5 |
Correct |
66 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
8 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
1079 ms |
256 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
67 ms |
376 KB |
Output is correct |
3 |
Correct |
67 ms |
356 KB |
Output is correct |
4 |
Correct |
67 ms |
256 KB |
Output is correct |
5 |
Correct |
66 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
8 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Execution timed out |
1079 ms |
256 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |