제출 #45219

#제출 시각아이디문제언어결과실행 시간메모리
45219sorry_Benq캥거루 (CEOI16_kangaroo)C++17
0 / 100
5 ms728 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int DPplus[41][41][41]; int DPminus[41][41][41]; int main(){ int N, cs, cf; cin >> N >> cs >> cf; DPplus[2][1][2] = 1LL; DPminus[2][2][1] = 1LL; for (int i = 3; i <= 40; i++){ for (int j = 1; j <= i; j++){ for (int k = 1; k <= i; k++){ DPplus[i][j][k] = 0LL; DPminus[i][j][k] = 0LL; for (int l = 1; l <= j - 1; l++){ int eps = (k > j); DPminus[i][j][k] += DPplus[i - 1][l][k - eps]; DPminus[i][j][k] %= MOD; } for (int l = j + 1; l <= i; l++){ int eps = (k > j); DPplus[i][j][k] += DPminus[i - 1][l - 1][k - eps]; DPplus[i][j][k] %= MOD; } } } } cout << (DPplus[N][cs][cf] + DPminus[N][cs][cf]) % MOD << 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...