(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #443099

#TimeUsernameProblemLanguageResultExecution timeMemory
443099tranxuanbachKangaroo (CEOI16_kangaroo)C++17
100 / 100
38 ms15940 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define endl '\n' #define fi first #define se second #define For(i, l, r) for (int i = l; i < r; i++) #define ForE(i, l, r) for (int i = l; i <= r; i++) #define FordE(i, l, r) for (int i = l; i >= r; i--) #define Fora(v, a) for (auto v: a) #define bend(a) a.begin(), a.end() #define isz(a) ((signed)a.size()) using ll = long long; using ld = long double; using pii = pair <int, int>; using vi = vector <int>; using vpii = vector <pii>; using vvi = vector <vi>; const int maxN = 2e3 + 5, mod = 1e9 + 7; void sadd(int& x, int y){ if ((x += y) >= mod) x -= mod; return; } int add(int x, int y){ if ((x += y) >= mod) x -= mod; return x; } void ssub(int& x, int y){ if ((x -= y) < 0) x += mod; return; } int sub(int x, int y){ if ((x -= y) < 0) x += mod; return x; } int mul(int x, int y){ return 1ll * x * y % mod; } int binpow(int x, int y){ int ans = 1; while (y){ if (y & 1) ans = mul(ans, x); x = mul(x, x); y >>= 1; } return ans; } int inv(int x){ return binpow(x, mod - 2); } #define div __div__ int div(int x, int y){ return mul(x, binpow(y, mod - 2)); } int n, cs, cf; int dp[maxN][maxN]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("KEK.inp", "r", stdin); // freopen("KEK.out", "w", stdout); cin >> n >> cs >> cf; dp[0][0] = 1; int cap = 0; ForE(i, 1, n){ ForE(cc, 1, n){ if (i == cs or i == cf){ sadd(dp[i][cc], dp[i - 1][cc - 1]); sadd(dp[i][cc], dp[i - 1][cc]); continue; } sadd(dp[i][cc], mul(dp[i - 1][cc - 1], cc - cap)); sadd(dp[i][cc], mul(dp[i - 1][cc + 1], cc)); } if (i == cs or i == cf){ cap++; } } cout << dp[n][1] << endl; } /* ==================================================+ INPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ OUTPUT: | --------------------------------------------------| --------------------------------------------------| ==================================================+ */

Compilation message (stderr)

kangaroo.cpp: In function 'void sadd(int&, int)':
kangaroo.cpp:27:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   27 |     if ((x += y) >= mod) x -= mod; return;
      |     ^~
kangaroo.cpp:27:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   27 |     if ((x += y) >= mod) x -= mod; return;
      |                                    ^~~~~~
kangaroo.cpp: In function 'int add(int, int)':
kangaroo.cpp:31:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |     if ((x += y) >= mod) x -= mod; return x;
      |     ^~
kangaroo.cpp:31:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |     if ((x += y) >= mod) x -= mod; return x;
      |                                    ^~~~~~
kangaroo.cpp: In function 'void ssub(int&, int)':
kangaroo.cpp:35:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   35 |     if ((x -= y) < 0) x += mod; return;
      |     ^~
kangaroo.cpp:35:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |     if ((x -= y) < 0) x += mod; return;
      |                                 ^~~~~~
kangaroo.cpp: In function 'int sub(int, int)':
kangaroo.cpp:39:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   39 |     if ((x -= y) < 0) x += mod; return x;
      |     ^~
kangaroo.cpp:39:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   39 |     if ((x -= y) < 0) x += mod; return x;
      |                                 ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...