제출 #551857

#제출 시각아이디문제언어결과실행 시간메모리
551857leaked캥거루 (CEOI16_kangaroo)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define f first #define s second #define m_p make_pair #define vec vector #define pb push_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define pw(x) (1LL<<(x)) #define sz(x) (int)(x).size() using namespace std; typedef long long ll; typedef pair<int,int> pii; const int M=1e9+7; void add(int &a,int b){ a+=b; if(a>=M) a-=M; else if(a<0) a+=M; } int mult(int a,int b){ return 1ll*a*b%M; } const int N=2e3+1; int dp[N][N]; /// len,pos and last was left/right signed main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,x,y; cin>>n>>x>>y;--x;--y; dp[1][1]=1; // dp[1][1]=1; for(int i=1;i<n;i++){ for(int c=0;c<=i;c++){ if(i==x || i==y){ /// if i just in beginning add(dp[i+1][c],dp[i][c]); add(dp[i+1][c+1],dp[i][c]); } else{ // /// if i choose between them // int cnt=(i-1)-(c-1); // // add(dp[i+1][c],mult(dp[i][c],cnt)); /// if i make new comp int w=c-(i>=x)-(i>=y); add(dp[i+1][c+1],mult(dp[i][c],w)); if(c) add(dp[i+1][c-1],mult(dp[i][c],c-1)); } // cout<<dp[i][c]<<' '; } // cout<<endl; } cout<<dp[n][1]; return 0; } /* 5 14 3 7 1 5 10 1 3 5 7 10 11 2 aa ab aa ca aa bc ea aa ad de aa */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...