This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, m;
cin >> n >> m;
int a[2 * n];
for (int i = 0; i < n; i++) {
a[i] = i + 1;
}
for (int i = 0; i < n; i++) {
a[i + n] = - (i + 1);
}
sort(a, a + 2 * n);
int cnt = 0;
do {
bool bad = 0;
for (int i = 0; i < 2 * n; i++) {
for (int j = i + 1; j < 2 * n; j++) {
if (abs(a[i]) == abs(a[j])) {
bad |= (j - i) % m == 0;
}
}
}
cnt += !bad;
} while(next_permutation(a, a + 2 * n));
cout << cnt << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |