Submission #261279

#TimeUsernameProblemLanguageResultExecution timeMemory
261279super_j6Kangaroo (CEOI16_kangaroo)C++14
36 / 100
2100 ms273880 KiB
#include <iostream> #include <cstdio> #include <algorithm> #include <unordered_map> using namespace std; #define endl '\n' #define ll long long #define pi pair<int, int> #define f first #define s second const int mod = 1000000007; const int mxn = 2001; int n, x, y; unordered_map<int, int> dp[mxn][mxn]; int sol(int n, int x, int y){ if(dp[n][x].count(y)) return dp[n][x][y]; int ret = 0; for(int i = (n & 1) * (x + 1); i < (n & 1 ? n : x); i++){ if(i != y) (ret += sol(n - 1, i - (n & 1), y - (x < y))) %= mod; } return dp[n][x][y] = ret; } int main(){ ios::sync_with_stdio(0); cin.tie(0); for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++){ dp[2][i][j] = 0; } dp[2][1][0] = 1; cin >> n >> x >> y; x--, y--; int ret = (sol(n, x, y) + sol(n, n - x - 1, n - y - 1)) % mod; cout << ret << endl; 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...