Submission #735808

#TimeUsernameProblemLanguageResultExecution timeMemory
735808danikoynovKangaroo (CEOI16_kangaroo)C++14
6 / 100
2 ms1584 KiB
/** ____ ____ ____ ____ ____ ____ ||l |||e |||i |||n |||a |||d || ||__|||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\|/__\| **/ #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 210; const ll mod = 1e9 + 7; int n, s, f; ll a[maxn][maxn][maxn]; ll d[maxn][maxn][maxn]; void add(ll &cell, ll val) { cell += val; if (cell >= mod) cell -= mod; } void solve() { cin >> n >> s >> f; if (s > f) swap(s, f); a[1][1][1] = d[1][1][1] = 1; for (int l = 2; l <= n; l ++) { for (int i = 1; i <= l; i ++) { for (int j = 1; j <= l; j ++) { if (i == j) continue; if (i > 1 && i <= j) { a[l][i][j] = a[l][i - 1][j] - d[l - 1][i - 1][j - 1]; } else { for (int g = i + 1; g <= n; g ++) { ll val = d[l - 1][g - 1][j - 1]; if (j < i) val = d[l - 1][g - 1][j]; add(a[l][i][j], val); } } for (int g = i - 1; g >= 0; g --) { ll val = a[l - 1][g][j]; if (j > i) val = a[l - 1][g][j - 1]; add(d[l][i][j], val); } ///cout << l << " " << i << " " << j << " " << a[l][i][j] << " " << d[l][i][j] << endl; } } } ll ans = (d[n][s][f] + a[n][s][f]) % mod; cout << ans << endl; } int main() { solve(); 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...