Submission #493910

#TimeUsernameProblemLanguageResultExecution timeMemory
493910khoabrightKangaroo (CEOI16_kangaroo)C++17
100 / 100
35 ms31608 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back #define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i) #define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i) #define all(x) x.begin(), x.end() const int N = 2e3 + 5; const int mod = 1e9 + 7; int dp[N][N]; main() { int n, a, b; cin >> n >> a >> b; dp[1][1] = 1; rep(i, 1, n - 1) rep(j, 1, n) { if (i + 1 == a || i + 1 == b) { (dp[i + 1][j] += dp[i][j]) %= mod; (dp[i + 1][j + 1] += dp[i][j]) %= mod; } else { // merge two components (dp[i + 1][j - 1] += dp[i][j] * (j - 1)) %= mod; // create a new component (dp[i + 1][j + 1] += (dp[i][j] * (j + 1 - (i + 1 > a) - (i + 1 > b)))) %= mod; } } cout << dp[n][1]; }

Compilation message (stderr)

kangaroo.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...