Submission #1117339

#TimeUsernameProblemLanguageResultExecution timeMemory
1117339Tai_xiuKangaroo (CEOI16_kangaroo)C++14
0 / 100
1 ms336 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define i128 int128 #define ii pair<int,int> #define ld long double #define vi vector<int> #define vvi vector<vi> #define vii vector<pair<int,int>> #define FOR(i,a,b) for (int i=a;i<=b;i++) #define FOR1(i,a,b,c) for (int i=a;i<=b;i+=c) #define REP(i,a,b) for (int i=a;i>=b;i--) #define REP1(i,a,b,c) for(int i=b;i>=a;i-=c) #define endh '\n'; #define len(a) a.length() #define pb(c) push_back(c) #define elif else if #define ppb() pop_back() #define rong std::npos #define all(c) (c.begin(),c.end()) #define Z int #define R double #define lcm(a,b) ((int) (a/__gcd(a,b))*b) #define mk(a,b) make_pair(a,b) Z dx4[]={-1,1,0,0}; Z dy4[]={0,0,1,-1}; string co="YES",khong="NO"; const int mod=1e9+7; Z dp[2003][2003]; Z mul(Z a,Z b) { ll tam=a; tam=a*1ll*b; tam%=mod; return tam; } void add(Z &a,Z b) { if ((a+=b)>=mod) a-=mod; } Z n,s,t; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>s>>t; dp[1][1]=1; FOR(i,2,n){ FOR(j,1,n){ if (i==s || i==t){ add(dp[i][j+1],dp[i-1][j]); add(dp[i][j],dp[i-1][j]); } else{ add(dp[i][j],mul(dp[i-1][j-1],j+1-(i>s)-(i>t))); add(dp[i][j-1],mul(dp[i-1][j],j-1)); } } } cout<<dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...