Submission #1322751

#TimeUsernameProblemLanguageResultExecution timeMemory
1322751bluocarootKangaroo (CEOI16_kangaroo)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using ll = long long; using namespace std; using namespace __gnu_pbds; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const double pi = acos(-1); const int N = 2e3 + 5, K = 1e3 + 5, SQ = 500, M = 1e9 + 7; //#define TESTS //#define INTERACTIVE //#define COMMUNICATION /* * Remember who you are. */ void pre() { } int dp[N][N][3], vis[N][N][3], vid, n, s, e; int rec(int i, int j, int k) { if (j < 0) return 0; if (i == n) return j == 1; auto &ret = dp[i][j][k], &v = vis[i][j][k]; if (v == vid) return ret; v = vid; ret = 0; int nk = k; if (s == i) nk |= 1; if (e == i) nk |= 2; if (s == i || e == i) ret = rec(i + 1, j + 1, nk) + rec(i + 1, j, nk); else ret = 1ll * rec(i + 1, j + 1, nk) * (j + 1 - __builtin_popcount(k)) % M + 1ll * rec(i + 1, j - 1, nk) * (j - 1) % M; return ret %= M; } void solve() { cin >> n >> s >> e; s--, e--; ++vid; cout << rec(0, 0, 0); // vector<vector<int>>dp(n + 1, vector<int>(n + 1)); // dp[1][1] = 1; // for (int i = 2; i <= n; ++i) // for (int j = 1; j <= n; ++j) // if (i == s || i == e) // dp[i][j] = (dp[]) } void solve2() { } signed main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); #ifdef CAROOT #ifndef INTERACTIVE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif #else freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); #endif int tt = 1; pre(); #ifdef COMMUNICATION string run; cin >> run; #endif #ifdef TESTS cin >> tt; #endif for (int tc = 1; tc <= tt; ++tc) { #ifdef COMMUNICATION if (run == "first") solve(); else solve2(); #else solve(); #endif cout << '\n'; } }

Compilation message (stderr)

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