Submission #559558

#TimeUsernameProblemLanguageResultExecution timeMemory
559558PherokungKangaroo (CEOI16_kangaroo)C++14
0 / 100
0 ms340 KiB
#include<bits/stdc++.h>
using namespace std;
#define N 2005
#define ll long long
const int mod = 1e9+7;
int n,cs,cf;
ll dp[N][N][3],ans;
int main(){
	scanf("%d%d%d",&n,&cs,&cf);
	
	dp[0][0][0] = 1;
	for(int idx=1;idx<=n;idx++){
		for(int comp=1;comp<=idx;comp++){
			for(int ex=0;ex<=2;ex++){
				if(idx == cs || idx == cf){
					if(ex == 0) continue;
					dp[idx][comp][ex] += dp[idx-1][comp][ex-1];
					dp[idx][comp][ex] %= mod;
					
					dp[idx][comp][ex] += dp[idx-1][comp-1][ex-1];
					dp[idx][comp][ex] %= mod;
				}
				else{
					dp[idx][comp][ex] += dp[idx-1][comp][ex] * (comp * 2 - ex);
					dp[idx][comp][ex] %= mod;
					
					dp[idx][comp][ex] += dp[idx-1][comp-1][ex] * (comp - ex);
					dp[idx][comp][ex] %= mod;
					
					dp[idx][comp][ex] += dp[idx-1][comp+1][ex] * (comp);
					dp[idx][comp][ex] %= mod;
				}
			}
		}
	}
	
	printf("%lld",dp[n][1][2]);
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d%d",&n,&cs,&cf);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...