#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5+1;
int n, cs, cf;
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> cs >> cf;
// sol <= (n-2)!
vector<int> p(n);
iota(p.begin(), p.end(), 1);
int sol = 0;
do {
if (p[0] != cs || p[n-1] != cf) continue;
int f = p[0] < p[1];
cerr << p[0];
for (int i = 1; i < n; i++) {
cerr << p[i];
if (f && p[i-1] > p[i]) {f = -1; break;}
if (!f && p[i-1] < p[i]) {f = -1; break;}
f = !f;
}
cerr << endl;
if (f != -1) sol++;
} while (next_permutation(p.begin(), p.end()));
cout << sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Execution timed out |
2041 ms |
2624 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Execution timed out |
2041 ms |
2624 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Execution timed out |
2041 ms |
2624 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |