제출 #1004068

#제출 시각아이디문제언어결과실행 시간메모리
1004068ef10캥거루 (CEOI16_kangaroo)C++17
100 / 100
50 ms31836 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; #define LL long long #define MODULE 1000000007 int main() { std::ifstream input; input.open("kangaroo.in"); std::ofstream output; output.open("kangaroo.out"); LL N, s, f; cin >> N >> s >> f; LL ep = 0; LL dp[N+5][N+5]; memset(dp,0,sizeof(dp)); dp[1][1] = 1; if (s==1 || f==1) { ep++; } for (LL i = 2; i <= N; i++) { for (LL j = 1; j <= N; j++) { if (i == s || i == f) { if (j == 1) ep++; dp[i][j] += dp[i-1][j-1]; dp[i][j] %= MODULE; dp[i][j] += dp[i-1][j]; dp[i][j] %= MODULE; continue; } if (j-ep > 0) { dp[i][j] += (dp[i-1][j-1] * (j-ep)) % MODULE; dp[i][j] %= MODULE; } dp[i][j] += (dp[i-1][j+1]*j) % MODULE; dp[i][j] %= MODULE; } } cout << dp[N][1] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...