# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
604388 |
2022-07-25T05:32:03 Z |
Aleee |
Kangaroo (CEOI16_kangaroo) |
C++14 |
|
2000 ms |
126372 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2083 ms |
126372 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2083 ms |
126372 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Execution timed out |
2083 ms |
126372 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |