Submission #741034

#TimeUsernameProblemLanguageResultExecution timeMemory
741034uroskKangaroo (CEOI16_kangaroo)C++14
0 / 100
1 ms340 KiB
#define here cerr<<"===========================================\n" #define dbg(x) cerr<<#x<<": "<<x<<endl; #include "bits/stdc++.h" //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> #define ld double #define ll long long #define llinf 100000000000000000LL // 10^17 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pll pair<ll,ll> #define pld pair<ld,ld> #define all(a) a.begin(),a.end() #define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} #define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;} #define yes cout<<"YES"<<endl #define no cout<<"NO"<<endl #define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); using namespace std; //using namespace __gnu_pbds; #define mod 1000000007 ll add(ll x,ll y){ x+=y; if(x<0){ x%=mod; x+=mod; }else{ if(x>=mod) x%=mod; } return x; } ll mul(ll a,ll b){ ll ans = (a*b)%mod; if(ans<0) ans+=mod; return ans; } ll po(ll x,ll y){ if(y==0) return 1LL; ll ans = po(x,y/2); ans = mul(ans,ans); if(y&1) ans = mul(ans,x); return ans; } ll inv(ll x){return po(x,mod-2);} #define maxn 2005 ll n; ll st,en; ll dp[maxn][maxn]; void tc(){ cin >> n >> st >> en; dp[1][1] = 1; for(ll i = 2;i<=n;i++){ for(ll j = 1;j<=n;j++){ if(i==st||i==en) dp[i][j] = add(dp[i-1][j],dp[i-1][j-1]); else{ dp[i][j] = add(dp[i][j],mul(j+2-(i>st)-(i>en),dp[i-1][j+1])); dp[i][j] = add(dp[i][j],mul(j+1-(i>st)-(i>en),dp[i-1][j-1])); } } } cout<<dp[n][1]<<endl; } int main(){ daj_mi_malo_vremena int t; t = 1; while(t--){ tc(); } 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...