Submission #130565

#TimeUsernameProblemLanguageResultExecution timeMemory
130565keko37Kangaroo (CEOI16_kangaroo)C++14
36 / 100
5 ms1912 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 205; const int MOD = 1000000007; int n, x, y; int a[MAXN][MAXN][MAXN], d[MAXN][MAXN][MAXN]; int main () { cin >> n >> x >> y; if (n > 40) return 0; if (x > y) swap(x, y); a[2][1][2] = d[2][2][1] = 1; for (int len = 3; len <= n; len++) { for (int i = 1; i <= len; i++) { for (int j = 1; j <= len; j++) { if (j <= i) { if (len & 1) { a[len][i][j] = a[len][j][i]; d[len][i][j] = d[len][j][i]; } else { a[len][i][j] = d[len][j][i]; d[len][i][j] = a[len][j][i]; } } else { for (int k = i+1; k <= n; k++) { a[len][i][j] = (a[len][i][j] + d[len-1][k-1][j-1]) % MOD; } for (int k = 1; k < i; k++) { d[len][i][j] = (d[len][i][j] + a[len-1][k][j-1]) % MOD; } } } } } cout << (a[n][x][y] + d[n][x][y]) % MOD; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...