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

#TimeUsernameProblemLanguageResultExecution timeMemory
308921arnold518Kangaroo (CEOI16_kangaroo)C++14
100 / 100
71 ms32120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2000; const ll MOD = 1e9+7; int N, S, E; ll dp[MAXN+10][MAXN+10]; ll solve(int pos, int comp) { if(pos==N+1) { if(comp==1) return 1; else return 0; } ll &ret=dp[pos][comp]; if(ret!=-1) return ret; ret=0; if(pos==S) { ret+=solve(pos+1, comp); ret+=solve(pos+1, comp+1); } else if(pos==E) { ret+=solve(pos+1, comp); ret+=solve(pos+1, comp+1); } else if(pos<S) { if(comp>=2) ret+=(comp-1)*solve(pos+1, comp-1); ret+=(comp+1)*solve(pos+1, comp+1); } else if(pos<E) { if(comp>=2) ret+=(comp-1)*solve(pos+1, comp-1); ret+=(comp)*solve(pos+1, comp+1); } else { if(comp>=2) ret+=(comp-1)*solve(pos+1, comp-1); ret+=(comp-1)*solve(pos+1, comp+1); } ret%=MOD; //printf("%d %d : %lld\n", pos, comp, ret); return ret; } int main() { scanf("%d%d%d", &N, &S, &E); if(S>E) swap(S, E); memset(dp, -1, sizeof(dp)); printf("%lld\n", solve(1, 0)); }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:59:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   59 |  scanf("%d%d%d", &N, &S, &E); if(S>E) swap(S, E);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...