Submission #1692478
Source Code Expand
#include <bits/stdc++.h>
#define pb push_back
#define Y second
#define X first
#define dbg(x) if(1)cerr<< #x << " = "<<x<<endl;
#define _ <<", "<<
#define fr(a,b,c) for(int a=b,__=c;a<__;a++)
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int mdp[2001][2001];
ll dp[2001][2001][3];
ll go(int A,int B,int x){
if(x==2)return 1;
if(~dp[A][B][x])return dp[A][B][x];
if(A){
dp[A][B][x]=go(A-1,B,x);
}
else dp[A][B][x]=0;
fr(i,0,min(A+1,B)){
dp[A][B][x]+=go(A-i,i,x+1)*mdp[i][B-1];
dp[A][B][x]%=mod;
}
return dp[A][B][x];
}
int main(){
int a,b;
scanf("%d%d",&a,&b);
memset(dp,-1,sizeof dp);
fr(j,0,b)fr(i,0,j+1){
if(i==j)mdp[i][j]=1;
else if(j==0&&i!=0)mdp[i][j]=0;
else if(i)mdp[i][j]=mdp[i-1][j-1]+mdp[i][j-1];
else mdp[i][j]=mdp[i][j-1];
if(mdp[i][j]>=mod)mdp[i][j]-=mod;
}
fr(i,0,a+1)fr(x,0,2)dp[i][0][x]=1;
fr(i,0,b+1)fr(x,0,2)dp[0][i][x]=1;
fr(i,0,a+1)fr(j,0,b+1)dp[i][j][2]=1;
printf("%lld\n",go(a,b,0));
}
Submission Info
Submission Time
2017-10-18 21:23:18+0900
Task
E - Popping Balls
User
alpgc
Language
C++14 (GCC 5.4.1)
Score
0
Code Size
997 Byte
Status
TLE
Exec Time
2104 ms
Memory
109440 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:28:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a,&b);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
0 / 1600
Status
Set Name
Test Cases
Sample
example0.txt, example1.txt, example2.txt, example3.txt
All
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, example0.txt, example1.txt, example2.txt, example3.txt
Case Name
Status
Exec Time
Memory
000.txt
TLE
2104 ms
109440 KB
001.txt
AC
38 ms
109312 KB
002.txt
AC
25 ms
94592 KB
003.txt
AC
25 ms
94464 KB
004.txt
TLE
2104 ms
109440 KB
005.txt
TLE
2104 ms
109312 KB
006.txt
TLE
2104 ms
109184 KB
007.txt
TLE
2104 ms
109056 KB
008.txt
TLE
2104 ms
109056 KB
009.txt
TLE
2104 ms
109184 KB
010.txt
TLE
2104 ms
109440 KB
011.txt
TLE
2104 ms
109312 KB
012.txt
TLE
2104 ms
109056 KB
013.txt
TLE
2104 ms
109184 KB
014.txt
AC
233 ms
108800 KB
015.txt
AC
846 ms
102784 KB
016.txt
AC
99 ms
108800 KB
017.txt
AC
121 ms
104704 KB
018.txt
AC
36 ms
108800 KB
019.txt
AC
47 ms
109056 KB
020.txt
AC
878 ms
100736 KB
021.txt
AC
44 ms
102656 KB
022.txt
AC
613 ms
104704 KB
023.txt
AC
128 ms
106752 KB
024.txt
AC
896 ms
108928 KB
025.txt
AC
46 ms
102656 KB
026.txt
AC
1216 ms
108928 KB
027.txt
AC
144 ms
96512 KB
028.txt
AC
1785 ms
109056 KB
029.txt
AC
26 ms
98560 KB
030.txt
AC
182 ms
106752 KB
031.txt
AC
89 ms
100608 KB
032.txt
AC
36 ms
108800 KB
033.txt
TLE
2104 ms
102784 KB
034.txt
AC
25 ms
94464 KB
035.txt
AC
25 ms
94464 KB
036.txt
AC
25 ms
94464 KB
037.txt
AC
25 ms
94464 KB
038.txt
AC
25 ms
94464 KB
039.txt
AC
25 ms
94464 KB
040.txt
AC
25 ms
94464 KB
041.txt
AC
25 ms
94464 KB
042.txt
AC
25 ms
94464 KB
043.txt
AC
25 ms
94464 KB
example0.txt
AC
25 ms
94464 KB
example1.txt
AC
25 ms
94464 KB
example2.txt
AC
25 ms
94464 KB
example3.txt
TLE
2104 ms
108928 KB