(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 #124708

#TimeUsernameProblemLanguageResultExecution timeMemory
124708eriksuenderhaufKangaroo (CEOI16_kangaroo)C++11
100 / 100
33 ms23032 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> #define mem(a,v) memset((a), (v), sizeof (a)) #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%I64d", &(n)) #define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i]) #define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%I64d\n", (n)) #define pii pair<int, int> #define pil pair<int, long long> #define pll pair<long long, long long> #define vii vector<pii> #define vil vector<pil> #define vll vector<pll> #define vi vector<int> #define vl vector<long long> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef cc_hash_table<ll,int,hash<ll>> ht; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset; const double pi = acos(-1); const int MOD = 1e9 + 7; const int MOD2 = 1e9 + 9; const int INF = 1e9 + 7; const int MAXN = 2e3 + 5; const double eps = 1e-9; int n, cs, cf; ll dp[MAXN][MAXN]; ll solve(int x, int y) { dp[n+1][0] = 1; int fl = 0; for (int i = n; i > 0; i--) { for (int j = 1; j <= n - i + 1; j++) { if (i == cs) dp[i][j] = dp[i+1][j-x]; else if (i == cf) dp[i][j] = dp[i+1][j-y]; else dp[i][j] = (dp[i+1][j-1] * 1ll * (ll) (j - fl) + dp[i+1][j+1] * 1ll * (ll) j) % MOD; } if (i == cs || i == cf) fl++; } return dp[1][1]; } int main() { scanf("%d %d %d", &n, &cs, &cf); ll ans = (solve(0, (n+1)&1) + solve(1, n&1)) % MOD; printf("%lld\n", ans); return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:60:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &cs, &cf);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...