Submission #316521

# Submission time Handle Problem Language Result Execution time Memory
316521 2020-10-26T13:59:02 Z Dymo Kangaroo (CEOI16_kangaroo) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>

using namespace std;


#define pb    push_back
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define endl "\n"
const ll maxn=3e3+50;
const ll mod =1e9+7;
const ll base=1e17;

ll dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("test.inp", "r"))
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout) ;
    }
    ll n, st, ed;
    cin>>n>>st>>ed;
    if (st>ed)
        swap(st,ed);
        st++;
        ed++;
    dp[0][0]=1;




    for (ll i=1;  i<=n; i++)
    {
        for (ll j=0; j<=n; j++)
        {
            if (i!=st&&i!=ed)
            {

                // them 1 nhom loai 1;
                if (j)
                    dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
                // ghep 2 nhom loai 1;
               if (j>0)dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1)*j)%mod;
                // ghep nhom st va  nhom loai 1;
                if (i>st)
                {
                    dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1))%mod;
                }
                // ghep nhom ed va  nhom loai 1;
                if (i>ed)
                {
                    dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1))%mod;
                }
               // cout <<"WTF"<<endl;
            }
            else
            {
                /*if (i==3)
                {
                    cout <<"WTF"<<endl;
                }*/
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
               dp[i][j]=(dp[i][j]+dp[i-1][j+1]*(j+1))%mod;
            }
        }
    }
    // cout <<dp[2][0]<<" "<<dp[2][1]<<" "<<dp[2][2]<<endl;
    cout <<dp[n][0];
}

Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:30:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   30 |     if (st>ed)
      |     ^~
kangaroo.cpp:32:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   32 |         st++;
      |         ^~
kangaroo.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   26 |         freopen("test.out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct