Submission #741035

#TimeUsernameProblemLanguageResultExecution timeMemory
741035Danilo21Kangaroo (CEOI16_kangaroo)C++14
100 / 100
21 ms31776 KiB
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) __builtin_popcountll(a)
#define bithigh(a) 63-__builtin_clzll(a)
#define lg bithigh
ll highpow(ll a) { return 1LL << (ll)lg(a); }

using namespace std;

const ll LINF = 4e18;
const int mxN = 2e3+10, INF = 2e9, mod = 1e9+7;
ll n, s, f, a[mxN], dp[mxN][mxN];

void Solve(){

    cin >> n >> s >> f;
    int cnt = 0;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (i == s || i == f)
                dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;
            else
                dp[i][j] = ((j-cnt)*dp[i-1][j-1] + j*dp[i-1][j+1]) % mod;
        }
        if (i == s || i == f) cnt++;
    }
    cout << dp[n][1] << en;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;
    cerr << "Started!" << endl;

    int t = 1;
    //cin >> t;
    while (t--)
        Solve();

    return 0;
}

Compilation message (stderr)

kangaroo.cpp: In function 'long long int highpow(long long int)':
kangaroo.cpp:26:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   26 | #define bithigh(a) 63-__builtin_clzll(a)
      |                      ^
kangaroo.cpp:27:12: note: in expansion of macro 'bithigh'
   27 | #define lg bithigh
      |            ^~~~~~~
kangaroo.cpp:28:38: note: in expansion of macro 'lg'
   28 | ll highpow(ll a) { return 1LL << (ll)lg(a); }
      |                                      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...