| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1294006 | ezim1234 | Kangaroo (CEOI16_kangaroo) | C++20 | 1 ms | 332 KiB |
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define yes cout << "Yes" << "\n"
#define no cout << "No" << "\n"
#define pb push_back
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef vector <pii> vii;
typedef vector <ll> vi;
template<typename T>
void read(vector<T>& v) {
for (auto &x : v) cin >> x;
}
template<typename T>
void print(const vector<T>& v) {
for (auto &x : v) cout << x << ' ';
cout << "\n";
}
int f, s;
int n;
const ll MAX = 1e6 + 5;
const ll MOD = 1e9 + 7;
int rcs(int a, int b, map <int, int> mp) {
map <int, int> mp1 = mp;
mp1[a]++;
bool ok = false;
if (a < b) {
vi c;
for (int i = a + 1; i <= n; i++) {
if (mp1[i] == 0 && i != f && i != s) {
c.pb(i);
}
}
int say = 0;
if (c.size() == 0 && a < f) {
return 1;
}
else if (c.size() == 0) {
return 0;
}
else {
for (auto x : c) {
say += rcs(x, a, mp1);
say = say % MOD;
}
}
return say;
}
else {
vi c;
for (int i = a - 1; i >= 1; i--) {
if (mp1[i] == 0 && i != f && i != s) {
c.pb(i);
}
}
int say = 0;
if (c.size() == 0 && a > f) {
return 1;
}
else if (c.size() == 0) {
return 0;
}
else {
for (auto x : c) {
say += rcs(x, a, mp1);
say = say % MOD;
}
}
return say;
}
}
void solve() {
cin >> n >> s >> f;
int cem = 0;
map <int, int> mp;
mp[s]++;
for (int i = 1; i <= n; i++) {
if (i != s && i != f) {
cem += rcs(i, s, mp);
cem = cem % MOD;
}
}
cout << cem << '\n';
}
signed main() {
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
for (int i = 1; i <= t; i++) {
solve();
}
}
Compilation message (stderr)
| # | 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... | ||||
