(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #385919

#TimeUsernameProblemLanguageResultExecution timeMemory
385919Vladth11Kangaroo (CEOI16_kangaroo)C++14
100 / 100
40 ms23040 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define debug(x) cerr << #x << " " << x << "\n" #define debug_with_space(x) cerr << #x << " " << x << " " using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <long double, pii> muchie; typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> OST; const ll NMAX = 201; const ll INF = (1LL << 60); const ll MOD = 1000000007; const ll BLOCK = 225; const ll base = 31; const ll nr_of_bits = 21; ll dp[2001][2001]; void add(ll &x, ll v) { x += v; x %= MOD; } int main() { int n, a, b, i; cin >> n >> a >> b; dp[1][1] = 1; for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) { if(i == a) { add(dp[i][j], dp[i - 1][j]);///adaugam ori la ce mai din stanga componenta add(dp[i][j], dp[i - 1][j - 1]); ///ori ne facem noi o componenta noua } else if(i == b) { ///same story ca la a add(dp[i][j], dp[i - 1][j]); add(dp[i][j], dp[i - 1][j - 1]); } else { add(dp[i][j], (dp[i - 1][j + 1] * j) % MOD); ///mergeuim doua add(dp[i][j], (dp[i - 1][j - 1] * ((j - 2) + (i < a) + (i < b))) % MOD); ///facem o comp noua } } } cout << dp[n][1]; return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:29:18: warning: unused variable 'i' [-Wunused-variable]
   29 |     int n, a, b, i;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...