Submission #1005036

#TimeUsernameProblemLanguageResultExecution timeMemory
1005036Muaath_5Kangaroo (CEOI16_kangaroo)C++17
6 / 100
2041 ms2624 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...