Submission #307369

#TimeUsernameProblemLanguageResultExecution timeMemory
307369jungsnowKangaroo (CEOI16_kangaroo)C++14
0 / 100
2 ms384 KiB
#include<bits/stdc++.h>

using namespace std;

int main() {
    freopen("kangaroo.in", "r", stdin);
    freopen("kangaroo.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, st, en;
    cin >> n >> st >> en;
    int cn = 0;
    vector<int> v;
    int a[2001];
    for (int i = 1; i <= n; ++i) if (i != st && i != en) {
        v.push_back(i);
    }
    a[1] = st; a[n] = en;
    do {
        for (int i = 0; i < (int)v.size(); ++i)
            a[i + 2] = v[i];
        bool ok = 1;
        for (int i = 2; i < n; ++i) {
            if (a[i] > a[i - 1]) {
                if (a[i] < a[i + 1]) {
                    ok = 0;
                    break;
                }
            } else if (a[i] > a[i + 1]) {
                ok = 0;
                break;
            }
        }
//        if (ok) {
//            for (int i = 1; i <= n; ++i)
//                cout << a[i] << ' ';
//            cout << '\n';
//        }
        cn += ok;
    } while (next_permutation(v.begin(), v.end()));
    cout << cn << '\n';
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:6:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    6 |     freopen("kangaroo.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:7:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     freopen("kangaroo.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...