Submission #443320

#TimeUsernameProblemLanguageResultExecution timeMemory
4433201e18Kangaroo (CEOI16_kangaroo)C++14
0 / 100
5 ms332 KiB
#define _CRT_SECURE_NO_WARNINGS #include <random> #include <limits> #include <assert.h> #include <time.h> #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vector> #include <utility> #include <algorithm> #include <iterator> #include <numeric> #include <string> #include <set> #include <map> using namespace std; #define forn(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define mp make_pair #define mt make_tuple #define ff first #define ss second #define whats(a) cerr<<#a<<" "<<a<<endl; #define Mod(a,b) (((a)%(b)+(b))%(b)) #define sz(x) (int((x).size())) typedef long long ll; typedef int Int; //#define int ll typedef vector<int> vec; typedef vector<vec> mat; const int N = 2000; const int MOD = 1e9 + 7; int dp[N + 1][N + 1]; void cadd(int& a, int b) { a += b; if (a >= MOD)a -= MOD; } int mul(int a, int b) { ll res = a * b; return res % MOD; } Int main(Int argc, char* argv[]) { #ifdef Home freopen("inp.txt", "rb", stdin); #else freopen("kangaroo.in", "rb", stdin); freopen("kangaroo.out", "wb", stdout); #endif ios::sync_with_stdio(0); int n, cs, cf; cin >> n >> cs >> cf; cs--; cf--; dp[1][1] = 1; forn(i, 1, n) { forn(j, 1, n) { if (i == cs || i == cf) { cadd(dp[i + 1][j + 1], dp[i][j]); cadd(dp[i + 1][j], dp[i][j]); } else { if (j >= 2) { cadd(dp[i + 1][j - 1], mul(dp[i][j], j - 1)); } cadd(dp[i + 1][j + 1], mul(dp[i][j], j - 1)); } } } cout << dp[n][1] << endl; return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'Int main(Int, char**)':
kangaroo.cpp:19:29: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   19 | #define forn(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                             ^
kangaroo.cpp:65:5: note: in expansion of macro 'forn'
   65 |     forn(i, 1, n) {
      |     ^~~~
kangaroo.cpp:19:29: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   19 | #define forn(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
      |                             ^
kangaroo.cpp:66:9: note: in expansion of macro 'forn'
   66 |         forn(j, 1, n) {
      |         ^~~~
kangaroo.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen("kangaroo.in", "rb", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:55:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |     freopen("kangaroo.out", "wb", 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...