이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*If we keep holding onto yesterday, what are we going to be tomorrow?*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define dbg if(debugg)
#define F first
#define S second
bool debugg = false;
template <typename T>
using order_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007;
int n, s, e;
int dp[2001][2001];
void solve()
{
cin >> n >> s >> e;
dp[1][1] = 1;
for(int i = 2; i <= n; i ++){
for(int j = 1; j <= n; j ++){
if(i == s || i == e){
dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
}
else{
int x = (dp[i - 1][j + 1] * j) % mod;
int y = (dp[i - 1][j - 1] * (j - 2 + (j < s) + (j < e))) % mod;
dp[i][j] = (x + y) % mod;
}
}
}
cout << dp[n][1] << '\n';
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
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... |