//In the name of Allah the most beneficent, the most merciful.
#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,avx512,fma")
#define int long long
#define ar array
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define PI 3.1415926535897932384626433832795l
const int N = 205;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
// -------------------------<RNG>-------------------------
// RANDOM NUMBER GENERATOR
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.
//--------------------------------------------------------
//int defined as long long
int dp[N][N][N][2];
void solve() {
int n,cs,cf;
cin>>n>>cs>>cf;
dp[2][1][2][1]=1;
dp[2][2][1][0]=1;
for(int sz=3;sz<=n;sz++)
for(int st=1;st<=sz;st++)
for(int ed=1;ed<=sz;ed++){
if(st==ed)
continue;
// cout<<sz<<' '<<st<<' '<<ed<<endl;
//di==1
for(int nxt=st;nxt<sz;nxt++){
dp[sz][st][ed][1]+=dp[sz-1][nxt][ed-(st<ed)][0]%mod;
dp[sz][st][ed][1]%=mod;
}
//di==0
for(int nxt=1;nxt<st;nxt++){
dp[sz][st][ed][0]+=dp[sz-1][nxt][ed-(st<ed)][1]%mod;
dp[sz][st][ed][0]%=mod;
}
// cout<<dp[sz][st][ed][0]<<' '<<dp[sz][st][ed][1]<<endl;
// return;
}
cout<<(dp[n][cs][cf][0]+dp[n][cf][cs][1])%mod<<endl;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("billboard.in", "r", stdin);
// freopen("billboard.out", "w", stdout);
int tc = 1;
// cin >> tc;
for (int t = 1; t <= tc; t++) {
// cout << "Case #" << t << ": ";
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2552 KB |
Output is correct |
3 |
Incorrect |
1 ms |
3672 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2552 KB |
Output is correct |
3 |
Incorrect |
1 ms |
3672 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2552 KB |
Output is correct |
3 |
Incorrect |
1 ms |
3672 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |