답안 #481256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481256 2021-10-20T06:08:02 Z shafi 캥거루 (CEOI16_kangaroo) C++14
0 / 100
1 ms 332 KB
#include<bits/stdc++.h>
#define eb emplace_back
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define clr(ar) memset(ar, 0, sizeof(ar))
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef set<ll> si;
typedef multiset<ll> msi;
typedef map<ll,ll> mii;
const ll INF=1e9;
const ll MOD=1000000007;
ll dp[2001][2001];
int main()
{
    fastio;
    ll t;
    ll i,j,k;
    ll n,cs,cf;
    cin>>n>>cs>>cf;
    dp[1][1]=1;
    for(i=2;i<=n;i++){
        for(j=1;j<i;j++){
            if(i==cs) dp[i][j+1]+=dp[i-1][j],dp[i][j]+=dp[i-1][j];
            else if(i==cf) dp[i][j+1]+=dp[i-1][j],dp[i][j]+=dp[i-1][j];
            else if(i>cs and i<cf) dp[i][j+1]+=dp[i-1][j]*j, dp[i][j]+=dp[i-1][j]*(2*j-1), dp[i][j-1]+=dp[i-1][j]*(j-1);
            else if(i>cf) dp[i][j+1]+=dp[i-1][j]*(j-1), dp[i][j]+=dp[i-1][j]*(2*j-2), dp[i][j-1]+=dp[i-1][j]*(j-1);
            else dp[i][j+1]+=dp[i-1][j]*(j+1), dp[i][j]+=dp[i-1][j]*(2*j), dp[i][j-1]+=dp[i-1][j]*(j-1);

            dp[i][j-1]%=MOD, dp[i][j]%=MOD, dp[i][j+1]%=MOD;
        }
    }
    cout<<dp[n][1]<<endl;
}

Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:26:8: warning: unused variable 't' [-Wunused-variable]
   26 |     ll t;
      |        ^
kangaroo.cpp:27:12: warning: unused variable 'k' [-Wunused-variable]
   27 |     ll i,j,k;
      |            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct