This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define itn int
#define INF 100000000
#define MOD 998244353
#define MAX 103
#define endl "\n"
#define ff first
#define ss second
using namespace std;
int temp;
int n, b;
int dp[2][MAX + 2];
int solve(int k, vector <int> v, int x) {
if (k == b && v.size() == n) {
return 1;
}
if (k == b) return 0;
if (dp[x][k] != -1) return dp[x][k];
if (x) {
bool c = false;
for (int i=k+1; i <= n; i++) {
if (find(v.begin(), v.end(), i) == v.end()) {
c = true;
cout << k << i << endl;
v.push_back(i);
dp[1][k] += solve(i, v, 0);
v.pop_back();
}
}
if (!c) return 0;
}
else {
bool c = false;
for (int i=1; i < k; i++) {
if (count(v.begin(), v.end(), i) == 0) {
c = true;
cout << k << i << endl;
v.push_back(i);
dp[0][k] += solve(i, v, 1);
v.pop_back();
}
}
if (!c) return 0;
}
return dp[x][k];
}
signed main() {
GOOD_LUCK
int t;
t = 1;
// cin >> t;
while (t--) {
int a;
cin >> n >> a >> b;
vector <int> v;
cout << solve(a, v, 0) + solve(a, v, 1);
}
return 0;
}
// Problem C
// by Ekber_Ekber
Compilation message (stderr)
kangaroo.cpp: In function 'int solve(int, std::vector<int>, int)':
kangaroo.cpp:18:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
18 | if (k == b && v.size() == n) {
| ~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |