Submission #789786

#TimeUsernameProblemLanguageResultExecution timeMemory
789786chengcheng567캥거루 (CEOI16_kangaroo)C++14
100 / 100
20 ms33160 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
int dp[2100][2100],n,a,b;
int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cin>>n>>a>>b;
	if(a>b)swap(a,b);dp[1][1]=1;
	for(int i=2;i<=n;i++)
    	for(int j=1;j<=n;j++)
    		if(i==a||i==b)dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%MOD;
    		else if(i<a)dp[i][j]=(j*dp[i-1][j-1]+j*dp[i-1][j+1])%MOD;
    		else if(a<i&&i<b)dp[i][j]=((j-1)*dp[i-1][j-1]+j*dp[i-1][j+1])%MOD;
    		else dp[i][j]=(max(0ll,j-2)*dp[i-1][j-1]+j*dp[i-1][j+1])%MOD;
	return cout<<dp[n][1],0;
}

Compilation message (stderr)

kangaroo.cpp: In function 'int32_t main()':
kangaroo.cpp:9:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    9 |  if(a>b)swap(a,b);dp[1][1]=1;
      |  ^~
kangaroo.cpp:9:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    9 |  if(a>b)swap(a,b);dp[1][1]=1;
      |                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...