Submission #307369

# Submission time Handle Problem Language Result Execution time Memory
307369 2020-09-28T02:44:25 Z jungsnow Kangaroo (CEOI16_kangaroo) C++14
0 / 100
2 ms 384 KB
#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

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 time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -