제출 #446883

#제출 시각아이디문제언어결과실행 시간메모리
446883aniervsKangaroo (CEOI16_kangaroo)C++17
0 / 100
0 ms332 KiB
#ifdef LOCAL #include <prettyprint.hpp> #endif #include<bits/stdc++.h> #define endl '\n' #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define lg2(x) __lg(x) #define rem_dupl(x) sort(all(x)); x.erase(unique(all(x)), x.end()) using namespace std; typedef long long ll; typedef double db; typedef pair<int,int> ii; #define x first #define y second //mt19937 rand32(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 rand64(chrono::steady_clock::now().time_since_epoch().count()); const db eps = 1e-9; const int maxn = (int)2e3 + 5; const ll mod = (int)1e9 + 7; // 998244353 ll mul(ll a, ll b){ return a * b % mod; } ll add(ll a, ll b){ return (a + b)%mod; } ll dp[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.setf(ios::fixed); cout.precision(0); int n, s, t; cin >> n >> s >> t; dp[1][1] = 1; for(int i = 1; i < n; i++) for(int j = 1; j <= i; j++){ if(i + 1 == s or i + 1 == t){ dp[i+1][j] = add(dp[i + 1][j], dp[i][j]); dp[i+1][j+1] = add(dp[i + 1][j + 1], dp[i][j]); continue; } dp[i+1][j+1] = add(dp[i+1][j+1], mul(dp[i][j], j + 1 - (int)(i >= s) - (int)(i >= t))); dp[i+1][j-1] = add(dp[i+1][j-1], mul(dp[i][j], j - 1)); dp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], 2*(j-1) + (int)(i < t) + (int)(i < s))); } cout << dp[n][1]; 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...