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

#TimeUsernameProblemLanguageResultExecution timeMemory
116520JohnTitorKangaroo (CEOI16_kangaroo)C++11
100 / 100
17 ms508 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, j, k) for(int i=(j); i<=(k); i++) #define FFOR(i, j, k) for(int i=(j); i<(k); i++) #define DFOR(i, j, k) for(int i=(j); i>=(k); i--) #define bug(x) cerr<<#x<<" = "<<(x)<<'\n' #define pb push_back #define mp make_pair #define bit(s, i) (((s)>>(i))&1LL) #define mask(i) ((1LL<<(i))) #define builtin_popcount __builtin_popcountll #define __builtin_popcount __builtin_popcountll using ll=long long; using ld=long double; mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2; template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);} template <typename T> inline void writeln(T x){write(x); putchar('\n');} #define taskname "Kangaroo" int n; ll f[2002]; ll g[2002]; int s, e; const ll base=1000000007; int main(){ #ifdef Aria if(fopen(taskname".in", "r")) freopen(taskname".in", "r", stdin); #endif // Aria f[1]=1; read(n); read(s); read(e); DFOR(i, n-1, 1){ FOR(j, 1, n) g[j]=0; if(i==s||i==e){ FOR(j, 1, n) if(f[j]) g[j]=(g[j]+f[j])%base; FOR(j, 1, n) if(f[j]) g[j+1]=(g[j+1]+f[j])%base; } else{ FOR(j, 1, n) if(f[j]){ g[j-1]=(g[j-1]+f[j]*(j-1))%base; g[j+1]=(g[j+1]+f[j]*(j-1))%base; if(i>e) g[j+1]=(g[j+1]+f[j])%base; if(i>s) g[j+1]=(g[j+1]+f[j])%base; } } FOR(j, 1, n) f[j]=g[j]; // bug(i); // FOR(i, 1, n) cerr<<f[i]<<" \n"[i==n]; } writeln(f[1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...