Submission #400729

#TimeUsernameProblemLanguageResultExecution timeMemory
400729hltkKangaroo (CEOI16_kangaroo)C++17
100 / 100
36 ms16808 KiB
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
int n, cs, cr, dp[2111][2111];
void mAdd(int &a, int b) { a += b; if (a >= M) a -= M; }
int main() {
	scanf("%d %d %d", &n, &cs, &cr);
	dp[1][1] = 1;
	for (int i = 2; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) {
			if (i == cs || i == cr) {
				dp[i][j] = dp[i - 1][j];
				mAdd(dp[i][j], dp[i - 1][j - 1]);
			} else {
				mAdd(dp[i][j], 1ll * dp[i - 1][j - 1] * (j - (i > cs) - (i > cr)) % M);
				mAdd(dp[i][j], 1ll * dp[i - 1][j + 1] * j % M);
			}
		}
	}
	printf("%d\n", dp[n][1]);
}

Compilation message (stderr)

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