Submission #57381

#TimeUsernameProblemLanguageResultExecution timeMemory
57381mraronKangaroo (CEOI16_kangaroo)C++14
6 / 100
3 ms524 KiB
/* ID: noszaly1 TASK: {TASK} LANG: C++11 */ //Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium #include<iostream> #include<vector> #include<map> #include<set> #include<cassert> #include<cassert> #include<unordered_map> #include<unordered_set> #include<functional> #include<queue> #include<stack> #include<cstring> #include<algorithm> #include<cmath> #include<sstream> #include<iomanip> #include<cstdio> #include<cstdlib> #include<numeric> using namespace std; #define all(x) (x).begin(), (x).end() #define pb push_back #define xx first #define yy second #define sz(x) (int)(x).size() #define gc getchar #define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define mp make_pair typedef long long ll; typedef unsigned long long ull; typedef long double ld; const double PI=acos(-1); template<typename T> T getint() { T val=0; char c; bool neg=false; while((c=gc()) && !(c>='0' && c<='9')) { neg|=c=='-'; } do { val=(val*10)+c-'0'; } while((c=gc()) && (c>='0' && c<='9')); return val*(neg?-1:1); } #define int ll int dp[2001][2001]; const int mod=1e9+7; main() { IO; int n, s, f; cin>>n>>s>>f; if(n==2) { cout<<"1\n"; return 0; } if(s>f) swap(s,f); dp[1][1]=1; for(int i=2;i<=n;++i) { //cerr<<i<<": "; for(int j=1;j<=i;++j) { if(i<s) { dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]*(j+1)*j)%mod; }else if(i==s) { dp[i][j]=(dp[i-1][j-1]+j*dp[i-1][j])%mod; }else if(s<i && i<f) { dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]*j*j)%mod; }else if(i==f) { dp[i][j]=(dp[i-1][j-1]+(j-1)*dp[i-1][j])%mod; }else if(f<i && i!=n) { dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]*(2*j+(j-1)*(j-1)-2))%mod; }else if(i==n) { dp[i][j]=(dp[i-1][j-1]+dp[i-1][j+1]*(2*j+(j-1)*(j-1)-1))%mod; } //cerr<<dp[i][j]<<" \n"[i==j]; } } cout<<dp[n][1]<<"\n"; return 0; }

Compilation message (stderr)

kangaroo.cpp:66:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...