# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
24906 |
2017-06-17T05:41:30 Z |
khsoo01 |
마스코트 (JOI13_mascots) |
C++11 |
|
163 ms |
142904 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll r, c, n, dt[3005][3005], fac[9000005], inv[3005];
ll xs = mod, xe = -mod, ys = mod, ye = -mod, w, h;
ll calc (ll X, ll Y) {
if(!Y) return 1;
ll ret = calc(X, Y/2);
ret = ret * ret % mod;
if(Y & 1) ret = ret * X % mod;
return ret;
}
ll com (ll X, ll Y) {
return fac[X] * inv[Y] % mod * inv[X-Y] % mod;
}
int main()
{
scanf("%lld%lld%lld",&r,&c,&n);
for(ll i=1;i<=n;i++) {
ll X, Y;
scanf("%lld%lld",&X,&Y);
xs = min(X, xs); xe = max(X, xe);
ys = min(Y, ys); ye = max(Y, ye);
}
fac[0] = 1; inv[0] = 1;
for(ll i=1;i<=r*c;i++) {
fac[i] = fac[i-1] * i % mod;
}
for(ll i=1;i<=max(r,c);i++) {
inv[i] = calc(fac[i], mod-2);
}
w = xe - xs + 1;
h = ye - ys + 1;
dt[w][h] = fac[w*h-n];
for(ll i=w;i<=r;i++) for(ll j=h;j<=c;j++) {
dt[i][j] = (dt[i][j] + dt[i-1][j] * fac[j] + dt[i][j-1] * fac[i]) % mod;
}
printf("%lld\n",dt[r][c] * com(r-w, xs-1) % mod * com(c-h, ys-1) % mod);
}
Compilation message
mascots.cpp: In function 'int main()':
mascots.cpp:22:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%lld",&r,&c,&n);
^
mascots.cpp:25:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&X,&Y);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
142904 KB |
Output is correct |
2 |
Correct |
0 ms |
142904 KB |
Output is correct |
3 |
Correct |
0 ms |
142904 KB |
Output is correct |
4 |
Correct |
0 ms |
142904 KB |
Output is correct |
5 |
Correct |
0 ms |
142904 KB |
Output is correct |
6 |
Correct |
0 ms |
142904 KB |
Output is correct |
7 |
Correct |
0 ms |
142904 KB |
Output is correct |
8 |
Correct |
0 ms |
142904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
142904 KB |
Output is correct |
2 |
Correct |
0 ms |
142904 KB |
Output is correct |
3 |
Correct |
0 ms |
142904 KB |
Output is correct |
4 |
Correct |
0 ms |
142904 KB |
Output is correct |
5 |
Correct |
0 ms |
142904 KB |
Output is correct |
6 |
Correct |
0 ms |
142904 KB |
Output is correct |
7 |
Correct |
0 ms |
142904 KB |
Output is correct |
8 |
Correct |
0 ms |
142904 KB |
Output is correct |
9 |
Correct |
0 ms |
142904 KB |
Output is correct |
10 |
Correct |
0 ms |
142904 KB |
Output is correct |
11 |
Correct |
0 ms |
142904 KB |
Output is correct |
12 |
Correct |
0 ms |
142904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
142904 KB |
Output is correct |
2 |
Correct |
0 ms |
142904 KB |
Output is correct |
3 |
Correct |
0 ms |
142904 KB |
Output is correct |
4 |
Correct |
16 ms |
142904 KB |
Output is correct |
5 |
Correct |
6 ms |
142904 KB |
Output is correct |
6 |
Correct |
39 ms |
142904 KB |
Output is correct |
7 |
Correct |
9 ms |
142904 KB |
Output is correct |
8 |
Correct |
29 ms |
142904 KB |
Output is correct |
9 |
Correct |
86 ms |
142904 KB |
Output is correct |
10 |
Correct |
119 ms |
142904 KB |
Output is correct |
11 |
Correct |
99 ms |
142904 KB |
Output is correct |
12 |
Correct |
86 ms |
142904 KB |
Output is correct |
13 |
Correct |
9 ms |
142904 KB |
Output is correct |
14 |
Correct |
53 ms |
142904 KB |
Output is correct |
15 |
Correct |
146 ms |
142904 KB |
Output is correct |
16 |
Correct |
106 ms |
142904 KB |
Output is correct |
17 |
Correct |
69 ms |
142904 KB |
Output is correct |
18 |
Correct |
163 ms |
142904 KB |
Output is correct |