Submission #601661

# Submission time Handle Problem Language Result Execution time Memory
601661 2022-07-22T09:01:06 Z Soumya1 Kangaroo (CEOI16_kangaroo) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#ifdef __LOCAL__
  #include <debug_local.h>
#endif
using namespace std;
const int mod = 1e9 + 7;
void testCase() {
  int n, s, f;
  cin >> n >> s >> f;
  vector<int> dp(n + 1);
  dp[1] = 1;
  auto add = [&](int a, int b) { return (a + b) % mod; };
  auto mul = [&](int a, int b) { return (1LL * a * b) % mod; };
  auto add_self = [&](int &a, int b) { return (a += b) %= mod; };
  for (int i = 1; i < n; i++) {
    vector<int> new_dp(n + 1);
    for (int j = 1; j <= i; j++) {
      if (i == s || i == f) {
        add_self(new_dp[j], dp[j]);
        add_self(new_dp[j + 1], dp[j]);
        continue;
      }
      int c = (i > s) + (i > f);
      add_self(new_dp[j + 1], mul(dp[j], j + 1 - c));
      add_self(new_dp[j], mul(dp[j], 2 * j - c));
      if (j > 0) add_self(new_dp[j - 1], mul(dp[j], j - 1));
    }
    dp = new_dp;
  }
  cout << dp[1] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  testCase();
}

Compilation message

kangaroo.cpp: In function 'void testCase()':
kangaroo.cpp:12:8: warning: variable 'add' set but not used [-Wunused-but-set-variable]
   12 |   auto add = [&](int a, int b) { return (a + b) % mod; };
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -