# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
48308 |
2018-05-11T16:09:17 Z |
wasyl |
Kangaroo (CEOI16_kangaroo) |
C++11 |
|
1293 ms |
128176 KB |
#include <bits/stdc++.h>
#ifndef DBG
#define dbg(...)
#else
#define dbg(...) {cerr << "\033[1;96m"; __VA_ARGS__; cerr << "\033[0m";}
#endif
#define bgn(...) begin(__VA_ARGS__)
#define rsz(...) resize(__VA_ARGS__)
#define emp(...) emplace_back(__VA_ARGS__)
#define psh(...) push_back(__VA_ARGS__)
#define ddmp(...) dbg(dmp(__VA_ARGS__))
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) print(cerr, #__VA_ARGS__, '=', __VA_ARGS__)
#define all(...) bgn(__VA_ARGS__), end(__VA_ARGS__)
#define siz(...) static_cast< int >((__VA_ARGS__).size())
using namespace std; using ll = long long;
template< typename... t > using V = vector< t... >;
template< typename... t > using outit = ostream_iterator< t... >;
template< typename t > void print(ostream& os, const t& a)
{os << a << '\n';} template< typename t, typename... v >
void print(ostream& os, const t& a, v&&... b){os << a << ' '; print(os, b...);}
constexpr int mod = 1e9 + 7, maxn = 2e2;
int n, cs, cf;
int dp[maxn + 1][maxn + 1][maxn + 1][2];
int kangaroo(int n, int cs, int cf, bool fl)
{
if (dp[n][cs][cf][fl] != -1)
return dp[n][cs][cf][fl];
if (n > 1 and cs == cf)
return dp[n][cs][cf][fl] = 0;
if (n == 1 and cs == cf)
return dp[n][cs][cf][fl] = 1;
int res = 0;
for (int i = 1; i <= n; ++i)
{
if (i == cs)
continue;
if ((not fl and i < cs) or (fl and i > cs))
continue;
int ncs = cs < i? i - 1 : i;
int ncf = cs < cf? cf - 1 : cf;
res = (res + kangaroo(n - 1, ncs, ncf, 1 - fl)) % mod;
}
return dp[n][cs][cf][fl] = res;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> cs >> cf;
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= n; ++j)
for (int k = 0; k <= n; ++k)
dp[i][j][k][0] = dp[i][j][k][1] = -1;
prt((kangaroo(n, cs, cf, false) + kangaroo(n, cs, cf, true)) % mod);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
1752 KB |
Output is correct |
4 |
Correct |
5 ms |
3388 KB |
Output is correct |
5 |
Correct |
4 ms |
3388 KB |
Output is correct |
6 |
Correct |
6 ms |
3504 KB |
Output is correct |
7 |
Correct |
5 ms |
3504 KB |
Output is correct |
8 |
Correct |
4 ms |
3504 KB |
Output is correct |
9 |
Correct |
5 ms |
3504 KB |
Output is correct |
10 |
Correct |
5 ms |
3504 KB |
Output is correct |
11 |
Correct |
5 ms |
3504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
1752 KB |
Output is correct |
4 |
Correct |
5 ms |
3388 KB |
Output is correct |
5 |
Correct |
4 ms |
3388 KB |
Output is correct |
6 |
Correct |
6 ms |
3504 KB |
Output is correct |
7 |
Correct |
5 ms |
3504 KB |
Output is correct |
8 |
Correct |
4 ms |
3504 KB |
Output is correct |
9 |
Correct |
5 ms |
3504 KB |
Output is correct |
10 |
Correct |
5 ms |
3504 KB |
Output is correct |
11 |
Correct |
5 ms |
3504 KB |
Output is correct |
12 |
Correct |
1286 ms |
64040 KB |
Output is correct |
13 |
Correct |
748 ms |
64040 KB |
Output is correct |
14 |
Correct |
92 ms |
64060 KB |
Output is correct |
15 |
Correct |
1143 ms |
64376 KB |
Output is correct |
16 |
Correct |
150 ms |
64376 KB |
Output is correct |
17 |
Correct |
1293 ms |
64384 KB |
Output is correct |
18 |
Correct |
310 ms |
64384 KB |
Output is correct |
19 |
Correct |
1179 ms |
64384 KB |
Output is correct |
20 |
Correct |
1199 ms |
64392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
1752 KB |
Output is correct |
4 |
Correct |
5 ms |
3388 KB |
Output is correct |
5 |
Correct |
4 ms |
3388 KB |
Output is correct |
6 |
Correct |
6 ms |
3504 KB |
Output is correct |
7 |
Correct |
5 ms |
3504 KB |
Output is correct |
8 |
Correct |
4 ms |
3504 KB |
Output is correct |
9 |
Correct |
5 ms |
3504 KB |
Output is correct |
10 |
Correct |
5 ms |
3504 KB |
Output is correct |
11 |
Correct |
5 ms |
3504 KB |
Output is correct |
12 |
Correct |
1286 ms |
64040 KB |
Output is correct |
13 |
Correct |
748 ms |
64040 KB |
Output is correct |
14 |
Correct |
92 ms |
64060 KB |
Output is correct |
15 |
Correct |
1143 ms |
64376 KB |
Output is correct |
16 |
Correct |
150 ms |
64376 KB |
Output is correct |
17 |
Correct |
1293 ms |
64384 KB |
Output is correct |
18 |
Correct |
310 ms |
64384 KB |
Output is correct |
19 |
Correct |
1179 ms |
64384 KB |
Output is correct |
20 |
Correct |
1199 ms |
64392 KB |
Output is correct |
21 |
Runtime error |
194 ms |
128176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
22 |
Halted |
0 ms |
0 KB |
- |