답안 #73150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73150 2018-08-28T01:22:03 Z KLPP Tents (JOI18_tents) C++14
100 / 100
564 ms 282896 KB
#include<iostream>

using namespace std;
#define MOD 1000000007
typedef long long int lld;
lld DP[6000][6000];

lld trabalha(int x, int y){
	if(x<0 || y<0)return 0;
	if(DP[x][y]!=-1)return DP[x][y];
	lld ans=0;
	ans+=trabalha(x-1,y);
	ans%=MOD;
	ans+=4*y*trabalha(x-1,y-1);
	ans%=MOD;
	lld comb=y*(y-1);
	comb/=2;
	comb%=MOD;
	//cout<<ans<<endl;
	ans+=comb*trabalha(x-1,y-2);
	comb=y*(x-1);
	comb%=MOD;
	//cout<<ans<<endl;
	ans+=comb*trabalha(x-2,y-1);
	ans%=MOD;
	DP[x][y]=ans;
	return ans;
}
int main(){
	for(int i=0;i<6000;i++){
		for(int j=0;j<6000;j++){
			DP[i][j]=-1;
			if(i==0 || j==0)DP[i][j]=1;
		}
	}
	
	int x,y;
	cin>>x>>y;
	cout<<(trabalha(x,y)+MOD-1)%MOD<<endl;
	/*for(int i=0;i<=x;i++){
		for(int j=0;j<=y;j++){
			cout<<i<<" "<<j<<" "<<DP[i][j]<<endl;
		}
	}*/
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 282236 KB Output is correct
2 Correct 206 ms 282236 KB Output is correct
3 Correct 205 ms 282296 KB Output is correct
4 Correct 228 ms 282296 KB Output is correct
5 Correct 211 ms 282464 KB Output is correct
6 Correct 210 ms 282464 KB Output is correct
7 Correct 198 ms 282464 KB Output is correct
8 Correct 218 ms 282464 KB Output is correct
9 Correct 208 ms 282464 KB Output is correct
10 Correct 223 ms 282464 KB Output is correct
11 Correct 217 ms 282464 KB Output is correct
12 Correct 219 ms 282464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 282236 KB Output is correct
2 Correct 206 ms 282236 KB Output is correct
3 Correct 205 ms 282296 KB Output is correct
4 Correct 228 ms 282296 KB Output is correct
5 Correct 211 ms 282464 KB Output is correct
6 Correct 210 ms 282464 KB Output is correct
7 Correct 198 ms 282464 KB Output is correct
8 Correct 218 ms 282464 KB Output is correct
9 Correct 208 ms 282464 KB Output is correct
10 Correct 223 ms 282464 KB Output is correct
11 Correct 217 ms 282464 KB Output is correct
12 Correct 219 ms 282464 KB Output is correct
13 Correct 232 ms 282464 KB Output is correct
14 Correct 242 ms 282712 KB Output is correct
15 Correct 420 ms 282776 KB Output is correct
16 Correct 235 ms 282776 KB Output is correct
17 Correct 240 ms 282776 KB Output is correct
18 Correct 254 ms 282796 KB Output is correct
19 Correct 461 ms 282796 KB Output is correct
20 Correct 413 ms 282796 KB Output is correct
21 Correct 316 ms 282796 KB Output is correct
22 Correct 304 ms 282796 KB Output is correct
23 Correct 270 ms 282796 KB Output is correct
24 Correct 564 ms 282796 KB Output is correct
25 Correct 461 ms 282796 KB Output is correct
26 Correct 523 ms 282796 KB Output is correct
27 Correct 533 ms 282896 KB Output is correct