Submission #481051

#TimeUsernameProblemLanguageResultExecution timeMemory
481051naman1601Kangaroo (CEOI16_kangaroo)C++17
0 / 100
2 ms332 KiB
/* ++[---------->+<]>.-[------>+<]>-.++++++++.+++++.-[->+++++<]>-.-[--->++<]>--.+.[--->+<]>---.[->+++<]>++.++++++.-------.++++++.--[--->+<]>.-[->+++<]>-..+++++++++++++.[----->++<]>.------------.+[----->+<]>.--------.+++++++++++++.-------------.--[--->+<]>-.---[->++++<]>-.++++[->+++<]>.--[--->+<]>-.[->+++<]>++.-.+++.---.-[->+++<]>.-[--->++<]>+.++++.------.[--->+<]>---.+[----->+<]>.------------.+++++++.-------.--[--->+<]>---.+++[->+++<]>++..+++++++++.---------.-[->+++<]>.+[----->+<]>+.-------------.+++++++.+.----[->+++<]>-. */ #include <bits/stdc++.h> using namespace std; typedef long long big; typedef long double ludo; #define pbb pair<big, big> #define pii pair<int, int> #define fe first #define se second #define maxheap priority_queue #define mset multiset #define uset unordered_set #define umap unordered_map #define fr(i, s, e) for(int i = s; i < e; i++) #define revfr(i, s, e) for(int i = s - 1; i >= e; i--) #define getv(v, n) for(int i = 0; i < n; i++) cin >> v[i]; #define speed ios_base::sync_with_stdio(false); cin.tie(NULL) #define nl "\n" #ifdef naman1601 #define debug(text) cout << (#text) << ": " << text << endl; #else #define debug(text) #endif const big mod = 1000000007; // const big mod = 998244353; const big infinity = 1000000000000000000; const int inf = 1e9 + 5; const int maxn = 2005; big dp[maxn][maxn] = {0}; int n, s, f; void solve() { // fr(i, 0, maxn) fr(j, 0, maxn) dp[i][j] = -1; cin >> n >> s >> f; dp[1][1] = 1; fr(i, 2, n + 1) { fr(j, 1, i + 1) { if(i == s || i == f) { dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]; dp[i][j] %= mod; continue; } dp[i][j] = dp[i - 1][j + 1] * j + dp[i - 1][j - 1] * (j - (i > s) - (i > f)); dp[i][j] %= mod; } } cout << dp[n][1] << nl; } int main() { speed; int TC = 1; // cin >> TC; #ifndef naman1601 freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); #endif for(int tc = 1; tc <= TC; tc++) { // cout << "Case #" << tc << ": "; solve(); } return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:75:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |  freopen("kangaroo.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:76:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |  freopen("kangaroo.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...