Submission #316390

# Submission time Handle Problem Language Result Execution time Memory
316390 2020-10-26T08:52:21 Z Killer2501 Kangaroo (CEOI16_kangaroo) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "teamwork"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using namespace std;
using ll = long long;
using ull = unsigned long long;
const int N = 2005;
const ll mod = 1e9+7;
//const ll base = 200;
ll m, n, k, t, T, ans, s, e, u, v, cs, cf, tong, lab[N];
ll a[N], b[N], d[N], c[N], x[N], dp[N][N];
//string s;
vector<ll> kq, adj[N];
set<ll> st;
void sol()
{
    cin >> n >> cs >> cf;
    if(cs > cf)swap(cs, cf);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 0; j <= i; j ++)
        {
            if(i == cs || i == cf)
            {
                dp[i][j] = (dp[i][j] + dp[i-1][j+1]) % mod;
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
            }
            else
            {
                if(j)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * j * (j + 1) % mod ) % mod;
                if(i > cs)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * (j + 1) % mod ) % mod;
                if(i > cf)dp[i][j] = (dp[i][j] + dp[i-1][j+1] * (j + 1) % mod ) % mod;
                if(j)dp[i][j] = (dp[i][j] + dp[i-1][j-1] ) % mod;

            }
        }
    }
    cout << dp[n][0];

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".in", "r"))
    {
		freopen(task".in","r",stdin);
		freopen(task".out","w",stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();

}
/*

*/

Compilation message

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:56:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   56 |   freopen(task".in","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   57 |   freopen(task".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct