Submission #1294015

#TimeUsernameProblemLanguageResultExecution timeMemory
1294015ezim1234캥거루 (CEOI16_kangaroo)C++20
6 / 100
2094 ms572 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define yes cout << "Yes" << "\n" #define no cout << "No" << "\n" #define pb push_back #define F first #define S second typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair <int, int> pii; typedef vector <pii> vii; typedef vector <ll> vi; template<typename T> void read(vector<T>& v) { for (auto &x : v) cin >> x; } template<typename T> void print(const vector<T>& v) { for (auto &x : v) cout << x << ' '; cout << "\n"; } int f, s; int n; const ll MAX = 1e6 + 5; const ll MOD = 1e9 + 7; void solve() { int n, s, f; cin >> n >> s >> f; int say = 0; vi a; for (int i = 1; i <= n; i++) { a.pb(i); } do { bool ok = true; if (a[0] != s || a.back() != f) { ok = false; } for (int i = 1; i < a.size() - 1; i++) { if (a[i] > a[i + 1] && a[i] < a[i - 1]) { ok = false; } if (a[i] < a[i + 1] && a[i] > a[i - 1]) { ok = false; } } if (ok) { say++; } say = say % MOD; } while (next_permutation(all(a))); cout << say << '\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; for (int i = 1; i <= t; i++) { 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...