제출 #1294223

#제출 시각아이디문제언어결과실행 시간메모리
1294223esmabadal캥거루 (CEOI16_kangaroo)C++20
6 / 100
2095 ms716 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAX = 1e5 + 10;
vector<int> vt[MAX];
void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> e;
    for(int i = 1; i <= n; i++) {
        if(i != a && i != b) {
            e.push_back(i);
        }
    }
    int ans = 0;
    do{
        deque<int> vt;
        vt.push_back(a);
        for(int i = 0; i < e.size(); i++) {
            vt.push_back(e[i]);
        }
        int say = 0;
        vt.push_back(b);
        int k = vt.size();
        for(int i = 1; i < k - 1; i++) {
            if(vt[i - 1] <= vt[i] && vt[i] <= vt[i + 1]) {
                say++;
            }
        }
        for(int i = 1; i <= k - 2; i++) {
            if(vt[i - 1] >= vt[i] && vt[i] >= vt[i + 1]) {
                say++;
            }
        }
        if(say == 0) {
            ans++;
        }
    }while(next_permutation(e.begin(), e.end()));
    cout << ans << endl;
}
signed main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...