(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 #164781

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1647812019-11-23 10:54:52ttnhuy313Kangaroo (CEOI16_kangaroo)C++14
100 / 100
84 ms31992 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2005, MOD = 1e9 + 7;
int n, s, t, memo[N][N];
void add(int &a, int b) {
a = (a + b) % MOD;
return;
}
int calc(int pos, int k) {
if (pos == n + 1)
return (k == 1);
if (~memo[pos][k]) return memo[pos][k];
int ret = 0;
if (pos == s) {
add(ret, calc(pos + 1, k));
add(ret, calc(pos + 1, k + 1));
} else if (pos == t) {
add(ret, calc(pos + 1, k));
add(ret, calc(pos + 1, k + 1));
} else {
add(ret, calc(pos + 1, k + 1) * (k + 1 - (pos > s) - (pos > t)));
if (k >= 2) add(ret, calc(pos + 1, k - 1) * (k - 1));
}
return memo[pos][k] = ret;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

kangaroo.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 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...