# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52938 |
2018-06-27T08:14:16 Z |
노영훈(#1382) |
Kangaroo (CEOI16_kangaroo) |
C++11 |
|
5 ms |
1924 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=43, inf=2e9, MOD=1000000007;
int n, s, t;
int L[MX][MX][MX];
int R[MX][MX][MX];
/*
int l(int x, int y, int z);
int r(int x, int y, int z);
int l(int x, int y, int z){
int &res=L[x][y][z];
if(res>=0) return res;
res=0;
for(int k=0; k<=x; k++)
res=(res+r(k, x-k+1+y, z))%MOD;
return res;
}
int r(int x, int y, int z){
int &res=R[x][y][z];
if(res>=0) return res;
res=0;
for(int k=0; k<=y; k++)
res=(res+l(x+1+k, y-k, z))%MOD;
for(int k=0; k<=z; k++)
res=(res+r(z-k, k, y+1+x))%MOD;
return res;
}
*/
int l(int n, int s, int t);
int r(int n, int s, int t);
int l(int n, int s, int t){
int &res=L[n][s][t];
if(res>=0) return res;
res=0;
if(s<t){
for(int k=1; k<s; k++)
res=(res+r(n-1,k,t-1))%MOD;
}
else{
for(int k=1; k<t; k++)
res=(res+r(n-1,k,t))%MOD;
for(int k=t+1; k<s; k++)
res=(res+r(n-1,k,t))%MOD;
}
return res;
}
int r(int n, int s, int t){
int &res=R[n][s][t];
if(res>=0) return res;
res=0;
if(s<t){
for(int k=s+1; k<t; k++)
res=(res+l(n-1,k-1,t-1))%MOD;
for(int k=t+1; k<=n; k++)
res=(res+l(n-1,k-1,t-1))%MOD;
}
else{
for(int k=s+1; k<=n; k++)
res=(res+l(n-1,k-1,t))%MOD;
}
return res;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>s>>t;
/*
for(int i=0; i<=n; i++)
for(int j=0; j<=n; j++)
for(int k=0; k<=n; k++)
L[i][j][k]=R[i][j][k]=-1;
R[0][0][0]=1; L[0][0][0]=0;
for(int i=0; i<=n; i++, cout<<'\n')
for(int j=0; j<=n; j++, cout<<'\n')
for(int k=0; k<=n; k++)
cout<<r(i,j,k)<<' ';
cout<<(l(s-1,t-s-1,n-t)+r(s-1,t-s-1,n-t))%MOD;
*/
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
for(int k=1; k<=n; k++)
L[i][j][k]=R[i][j][k]=-1;
L[2][1][2]=R[2][2][1]=0;
L[2][2][1]=R[2][1][2]=1;
cout<<(l(n,s,t)+r(n,s,t))%MOD;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
584 KB |
Output is correct |
3 |
Correct |
2 ms |
944 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
4 ms |
1248 KB |
Output is correct |
7 |
Correct |
4 ms |
1248 KB |
Output is correct |
8 |
Correct |
3 ms |
1248 KB |
Output is correct |
9 |
Correct |
4 ms |
1248 KB |
Output is correct |
10 |
Correct |
3 ms |
1248 KB |
Output is correct |
11 |
Correct |
3 ms |
1248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
584 KB |
Output is correct |
3 |
Correct |
2 ms |
944 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
4 ms |
1248 KB |
Output is correct |
7 |
Correct |
4 ms |
1248 KB |
Output is correct |
8 |
Correct |
3 ms |
1248 KB |
Output is correct |
9 |
Correct |
4 ms |
1248 KB |
Output is correct |
10 |
Correct |
3 ms |
1248 KB |
Output is correct |
11 |
Correct |
3 ms |
1248 KB |
Output is correct |
12 |
Runtime error |
5 ms |
1924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
584 KB |
Output is correct |
3 |
Correct |
2 ms |
944 KB |
Output is correct |
4 |
Correct |
3 ms |
1248 KB |
Output is correct |
5 |
Correct |
3 ms |
1248 KB |
Output is correct |
6 |
Correct |
4 ms |
1248 KB |
Output is correct |
7 |
Correct |
4 ms |
1248 KB |
Output is correct |
8 |
Correct |
3 ms |
1248 KB |
Output is correct |
9 |
Correct |
4 ms |
1248 KB |
Output is correct |
10 |
Correct |
3 ms |
1248 KB |
Output is correct |
11 |
Correct |
3 ms |
1248 KB |
Output is correct |
12 |
Runtime error |
5 ms |
1924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |