# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
893609 | 2023-12-27T07:27:07 Z | vjudge1 | Kangaroo (CEOI16_kangaroo) | C++17 | 2000 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() const int N = (int)2e5 + 5; const int MAX = (int)1e9 + 5; const ll mod = (int)1e9 + 7; const ll inf = (int)(1e9) + 100; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve() { int n; cin >> n; int cs, cf; cin >> cs >> cf; vector<int> p; for (int i = 1; i <= n; i++) { p.pb(i); } int ans = 0; do { if (p[0] != cs) continue; if (p.back() != cf) continue; bool bad = 0; for (int i = 1; i < sz(p) - 1; i++) { if (!((p[i] > p[i - 1] && p[i] > p[i + 1]) || (p[i] < p[i - 1] && p[i] < p[i + 1]))) { bad = 1; break; } } ans += !bad; ans %= mod; } while (next_permutation(all(p))); cout << ans; } signed main() { //setIO("kangaroo"); ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T = 1; //cin >> T; while (T--) solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 504 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 504 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Execution timed out | 2057 ms | 348 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 504 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Execution timed out | 2057 ms | 348 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 504 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Execution timed out | 2057 ms | 348 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |