Submission #604388

#TimeUsernameProblemLanguageResultExecution timeMemory
604388AleeeKangaroo (CEOI16_kangaroo)C++14
6 / 100
2083 ms126372 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define all(a) (a).begin(), (a).end() #define endl '\n' #define forn(i, l, n) for (int i = l; i < int(n); i++) typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; typedef pair<int, int> pii; const int INF = 1e9 + 7; vll dp(2000, -1); vll cant(2001, 0); int n, cs, cf; vector<string> ans; void solve(int prev, int act, vector<bool> disp, int aux, string path) { if (aux == n) { if (act == cf) ans.pb(path); return; } // cout << prev << " -> " << act << " " << aux << endl; if (prev < act) { forn(i, 1, act) { if (!disp[i] || aux == n - 1) { cant[i]++; disp[i] = 1; aux++; solve(act, i, disp, aux, path + "->" + to_string(i)); disp[i] = 0; aux--; } } } else if (prev > act) { forn(i, act + 1, n + 1) { if (!disp[i] || aux == n - 1) { cant[i]++; disp[i] = 1; aux++; solve(act, i, disp, aux, path + "->" + to_string(i)); disp[i] = 0; aux--; } } } else { forn(i, 1, n + 1) { if (!disp[i] || aux == n - 1) { cant[i]++; disp[i] = 1; aux++; solve(act, i, disp, aux, path + "->" + to_string(i)); disp[i] = 0; aux--; } } } return; } int main() // Ale C. { ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("output.txt", "w", stdout); cin >> n >> cs >> cf; vector<bool> disp(2000, 0); disp[cs] = disp[cf] = 1; solve(cs, cs, disp, 1, to_string(cs)); cout << cant[cf] << endl; /* sort(all(ans)); forn(i, 0, ans.size()) cout << ans[i] << endl; */ 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...