# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
12992 |
2015-01-23T16:56:17 Z |
dohyun0324 |
마스코트 (JOI13_mascots) |
C++ |
|
132 ms |
142676 KB |
#include<stdio.h>
int x,y,q,n,m,minx=2147483647,miny=2147483647,maxx,maxy;
long long dap=1,d[3010][3010],fact[3010],comb[3010][3010];
int main()
{
int i,j;
scanf("%d %d",&n,&m);
scanf("%d",&q);
for(i=1;i<=q;i++)
{
scanf("%d %d",&x,&y);
if(minx>x) minx=x;
if(maxx<x) maxx=x;
if(miny>y) miny=y;
if(maxy<y) maxy=y;
}
fact[1]=1;
for(i=2;i<=3000;i++){fact[i]=fact[i-1]*i; fact[i]%=1000000007;}
for(i=1;i<=(maxx-minx+1)*(maxy-miny+1)-q;i++){dap*=i; dap%=1000000007;}
x=maxx-minx+1; y=maxy-miny+1;
comb[0][0]=1;
for(i=1;i<=3000;i++)
{
comb[i][0]=1;
for(j=1;j<=i;j++)
{
comb[i][j]=comb[i-1][j]+comb[i-1][j-1];
comb[i][j]%=1000000007;
}
}
d[x][y]=1;
for(i=x;i<=n;i++)
{
for(j=y;j<=m;j++)
{
if(i>x) d[i][j]+=d[i-1][j]*fact[j];
if(j>y) d[i][j]+=d[i][j-1]*fact[i];
d[i][j]%=1000000007;
}
}
dap*=d[n][m]; dap%=1000000007;
dap*=comb[n-x][minx-1]; dap%=1000000007;
dap*=comb[m-y][miny-1]; dap%=1000000007;
printf("%lld",dap);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
142676 KB |
Output is correct |
2 |
Correct |
24 ms |
142676 KB |
Output is correct |
3 |
Correct |
12 ms |
142676 KB |
Output is correct |
4 |
Correct |
12 ms |
142676 KB |
Output is correct |
5 |
Correct |
24 ms |
142676 KB |
Output is correct |
6 |
Correct |
4 ms |
142676 KB |
Output is correct |
7 |
Correct |
4 ms |
142676 KB |
Output is correct |
8 |
Correct |
0 ms |
142676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
142676 KB |
Output is correct |
2 |
Correct |
20 ms |
142676 KB |
Output is correct |
3 |
Correct |
16 ms |
142676 KB |
Output is correct |
4 |
Correct |
8 ms |
142676 KB |
Output is correct |
5 |
Correct |
20 ms |
142676 KB |
Output is correct |
6 |
Correct |
20 ms |
142676 KB |
Output is correct |
7 |
Correct |
16 ms |
142676 KB |
Output is correct |
8 |
Correct |
24 ms |
142676 KB |
Output is correct |
9 |
Correct |
16 ms |
142676 KB |
Output is correct |
10 |
Correct |
8 ms |
142676 KB |
Output is correct |
11 |
Correct |
8 ms |
142676 KB |
Output is correct |
12 |
Correct |
28 ms |
142676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
142676 KB |
Output is correct |
2 |
Correct |
8 ms |
142676 KB |
Output is correct |
3 |
Correct |
8 ms |
142676 KB |
Output is correct |
4 |
Correct |
36 ms |
142676 KB |
Output is correct |
5 |
Correct |
28 ms |
142676 KB |
Output is correct |
6 |
Correct |
48 ms |
142676 KB |
Output is correct |
7 |
Correct |
20 ms |
142676 KB |
Output is correct |
8 |
Correct |
24 ms |
142676 KB |
Output is correct |
9 |
Correct |
64 ms |
142676 KB |
Output is correct |
10 |
Correct |
88 ms |
142676 KB |
Output is correct |
11 |
Correct |
68 ms |
142676 KB |
Output is correct |
12 |
Correct |
92 ms |
142676 KB |
Output is correct |
13 |
Correct |
12 ms |
142676 KB |
Output is correct |
14 |
Correct |
84 ms |
142676 KB |
Output is correct |
15 |
Correct |
132 ms |
142676 KB |
Output is correct |
16 |
Correct |
64 ms |
142676 KB |
Output is correct |
17 |
Correct |
88 ms |
142676 KB |
Output is correct |
18 |
Correct |
120 ms |
142676 KB |
Output is correct |