This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <set>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double>
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>
#define vv vector
using namespace std;
const int MAXN = 2001;
const int MOD = 1e9 + 7;
ll dp[2001][2001];
int main(){
int n,a,b;
cin >> n >> a >> b;
FOR(i,n)FOR(j,n)dp[i][j] = 0;
a--;b--;
dp[0][0] = 1;
FOR(i,n){
if(i == 0)continue;
FOR(j,i+1){
ll sum = 0;
if(i%2 == 0){
FORE(k,j,n-1){
sum += dp[i-1][k];
sum %= MOD;
}
}else{
FORE(k,0,j-1){
sum += dp[i-1][k];
sum %= MOD;
}
}
dp[i][j] = sum;
}
}
FOR(i,n){
FOR(j,n){
// cout << dp[i][j] << " ";
}
//cout << endl;
}
cout << dp[n-1][b] << 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... |