(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #109085

#TimeUsernameProblemLanguageResultExecution timeMemory
109085DystoriaXKangaroo (CEOI16_kangaroo)C++14
100 / 100
187 ms47600 KiB
#include <bits/stdc++.h> using namespace std; int n, cs, cf; int dp[2010][2010][3]; const int MOD = 1e9 + 7; int add(long long a, long long b){ return (a + b) % MOD; } int mul(long long a, long long b){ return (a * b) % MOD; } int main(){ scanf("%d%d%d", &n, &cs, &cf); dp[0][0][0] = 1; for(int i = 1; i <= n; i++){ for(int j = 0; j <= n; j++){ for(int k = 0; k <= 2; k++){ if(k > j) continue; int v = dp[i - 1][j][k]; if(i != cf && i != cs){ dp[i][j - 1][k] = add(dp[i][j - 1][k], mul(v, j - 1)); dp[i][j + 1][k] = add(dp[i][j + 1][k], mul(v, j + 1 - k)); } else if (k < 2) { dp[i][j][k + 1] = add(dp[i][j][k + 1], v); dp[i][j + 1][k + 1] = add(dp[i][j + 1][k + 1], v); } } } } printf("%d\n", dp[n][1][2]); return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  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...