이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |