Submission #23897

#TimeUsernameProblemLanguageResultExecution timeMemory
23897khsoo01캥거루 (CEOI16_kangaroo)C++11
100 / 100
26 ms33424 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll n, s, e, dt[2005][2005];

ll solve (ll X, ll Y) {
	dt[n+1][0] = 1;
	ll ocu = 0;
	for(int i=n;i>=1;i--) {
		for(int j=1;j<=n-i+1;j++) {
			if(i == s) dt[i][j] = dt[i+1][j-X];
			else if(i == e) dt[i][j] = dt[i+1][j-Y];
			else dt[i][j] = (dt[i+1][j-1] * (j - ocu) + dt[i+1][j+1] * j) % mod;
		}
		if(i == s || i == e) ocu++;
	}
	return dt[1][1];
}

int main()
{
	scanf("%lld%lld%lld",&n,&s,&e);
	printf("%lld\n",(solve(0, (n+1)%2) + solve(1, n%2)) % mod);
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:23:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&s,&e);
                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...