#include <bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
signed main(){
int n,cs,cf;
cin>>n>>cs>>cf;
vector<int>arr(n);
for(int i=0;i<n;i++)
arr[i]=i+1;
int ans=0;
do{
bool flag=false;
if(arr[0]!=cs)continue;
if(arr[n-1]!=cf)continue;
for(int i=1;i<n-1;i++){
bool a1=arr[i]<arr[i-1];
bool a2=arr[i]<arr[i+1];
if(a1!=a2){
flag=true;
}
}
if(flag)continue;
ans++;
}while(next_permutation(arr.begin(),arr.end()));
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Execution timed out |
2044 ms |
600 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Execution timed out |
2044 ms |
600 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Execution timed out |
2044 ms |
600 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |