Submission #125562

# Submission time Handle Problem Language Result Execution time Memory
125562 2019-07-06T00:06:24 Z tutis Kangaroo (CEOI16_kangaroo) C++17
6 / 100
2000 ms 376 KB
/*input
4 2 3
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll modulo = 1000000007;
int sgn(ll x)
{
	if (x < 0)
		return -1;
	if (x > 0)
		return 1;
	return 0;
}
ll f(int n, int a, int b, int s)
{
	if (a == b)
		return 0;
	if (n == 2)
	{
		if (sgn(b - a) != s)
			return 0;
		else
			return 1;
	}
	ll ret = 0;
	for (int c = 1; c <= n; c++)
	{
		if (sgn(b - c) == s)
		{
			ret += f(n - 1, a - (a > b), c - (c > b), -s);
		}
	}
	ret %= modulo;
	return ret;
}
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	ll ans = f(n, a, b, 1) + f(n, a, b, -1);
	ans %= modulo;
	cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Execution timed out 2071 ms 376 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Execution timed out 2071 ms 376 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Execution timed out 2071 ms 376 KB Time limit exceeded
4 Halted 0 ms 0 KB -