Submission #1258508

#TimeUsernameProblemLanguageResultExecution timeMemory
1258508nikaa123Kangaroo (CEOI16_kangaroo)C++20
6 / 100
2094 ms324 KiB
#include <bits/stdc++.h> using namespace std; // #define int long long #define eb emplace_back #define mp make_pair #define pb push_back #define pp pop_back #define endl '\n' #define ff first #define ss second #define stop exit(0) #define sz(x) (int)x.size() #define pause system("pause") #define all(x) (x).begin(), (x).end() #define deb(x) cout << #x << "-" << x << endl typedef char chr; typedef string str; typedef long long ll; typedef vector<int> vii; typedef pair<int, int> pii; const long long INF = LLONG_MAX; const int inf = INT_MAX; const int mod = 998244353; const int MOD = 1e9 + 7; const int dx[] = {0, 0, -1, 1}; const int dy[] = {-1, 1, 0, 0}; const double PI = 2 * acos(0.0); const int N = 2e3 + 5; int n,cs,cf; int fix[N]; int ans; void rec(int rep, bool dir,int last) { if (rep != n && fix[cf]) { return; } if (rep == n) { if (last == cf) ans++; return; } if (dir) { bool ok = 0; for (int i = last+1; i <= n; i++) { if (!fix[i]) ok = 1; } if (!ok) { return; } for (int i = last+1; i <= n; i++) { if (!fix[i]) { fix[i] = 1; rec(rep+1,!dir,i); fix[i] = 0; } } } else { bool ok = 0; for (int i = last-1; i >= 1; i--) { if (!fix[i]) ok = 1; } if (!ok) { return; } for (int i = last-1; i >= 1; i--) { if (!fix[i]) { fix[i] = 1; rec(rep+1,!dir,i); fix[i] = 0; } } } } inline void test_case() { cin >> n >> cs >> cf; fix[cs] = 1; rec(1,1,cs); for (int i = 1; i <= n; i++) { fix[i] = 0; } fix[cs] = 1; rec(1,0,cs); cout << ans << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T = 1; // cin >> T; while (T--) { test_case(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...