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;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, P;
cin >> N >> P;
vector<int> a(2 * N);
iota(a.begin(), a.end(), 1);
int ans = 0;
do {
bool ok = 1;
for (int i = 0; i < N; i++) {
if (a[i] > a[N + i]) {
ok = 0;
}
if (i && a[i - 1] > a[i]) {
ok = 0;
}
}
if (!ok) {
continue;
}
int s = 0, f = 0;
for (int i = 0; i < N; i++) {
if (a[i] > f) {
s++;
f = max(f, a[i + N]);
}
}
int t = 0; f = 0;
vector<int> ord(N);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) {
return a[N + i] < a[N + j];
});
for (int i = 0; i < N; i++) {
if (i == 0 || a[ord[i]] > f) {
t++;
f = a[N + ord[i]];
}
}
if (s < t) {
ans++;
}
} while (next_permutation(a.begin(), a.end()));
cout << ans << "\n";
return 6/22;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |