Submission #834235

#TimeUsernameProblemLanguageResultExecution timeMemory
834235GondozuKangaroo (CEOI16_kangaroo)C++14
0 / 100
2 ms340 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define all(v) v.begin(),v.end() #define Gondozu ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL); using namespace std; using ll = long long; using pi = pair<int, int>; using vi = vector<int>; using vpi = vector <pair<int, int>>; using vvi = vector <vector<int>>; const int OO = 1e9 + 5; const int N = 2e3 + 5, MOD = 1e9+7; int n, s, e; ll dp[N][N]; ll add(ll a, ll b) { a += b; if (a >= MOD) a -= MOD; return a; } ll mul(ll a, ll b) { return a * b % MOD; } void TC() { cin >> n >> s >> e; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { ll &cur = dp[i][j]; if(i == 1){ cur = j == 1; continue; } if(i == s || i == e){ cur = add(dp[i-1][j], dp[i-1][j-1]); continue; } cur = add(mul(dp[i-1][j+1], j), mul(dp[i-1][j-1], j - (i>s) - (i>e))); } } cout << dp[n][1]; } int32_t main() { #ifndef ONLINE_JUDGE freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #else freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); #endif Gondozu int t = 1; // cin >> t; while (t--) { TC(); cout << '\n'; } return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int32_t main()':
kangaroo.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     freopen("input.in", "r", stdin); freopen("output.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:52:45: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     freopen("input.in", "r", stdin); freopen("output.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...