# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
35230 |
2017-11-19T08:00:05 Z |
wan2000 |
마스코트 (JOI13_mascots) |
C++14 |
|
0 ms |
213536 KB |
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline void read(T &x){
x = 0; char ch;
while(!isdigit(ch=getchar()));
do{x=10*x+ch-'0';}while(isdigit(ch=getchar()));
}
template<typename T> inline void write(T x){
if(x<=9){ putchar(x+'0'); return;}
write(x/10); putchar(x%10+'0');
}
template<typename T> inline void writeln(T x){
write(x); putchar('\n');
}
typedef long long ll;
const int N = 3003;
const ll MOD = 1e9+7;
int row, col, n;
ll F[N][N], Fac[N*N], BC[N][N], res;
void init(){
Fac[0] = 1;
for(int i = 1; i <= row*col; i++) Fac[i] = (Fac[i-1]*(ll)i)%MOD;
for(int i = 0; i <= max(row,col); i++) BC[0][i] = 1;
for(int i = 1; i <= max(row,col); i++){
BC[i][i] = 1;
for(int j = i+1; j <= max(row,col); j++){
BC[i][j] = (BC[i-1][j-1]+BC[i][j-1])%MOD;
}
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
read(row); read(col);
init();
read(n);
int u = N, v = N, p = 0, q = 0;
for(int i = 1; i <= n; i++){
int x, y;
read(x); read(y);
u = min(u,x);
v = min(v,y);
p = max(p,x);
q = max(q,x);
}
int x = p-u+1;
int y = q-v+1;
ll need = Fac[x*y-n];
F[row][col] = 1;
for(int i = row; i >= x; i--){
for(int j = col; j >= y; j--){
if(i==row&&j==col) continue;
F[i][j] = (F[i+1][j]*Fac[j]+F[i][j+1]*Fac[i])%MOD;
}
}
res = F[x][y]*BC[u-1][row-x]*BC[v-1][col-y]*need;
//writeln(res);
cout<<res<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
213536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
213536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
213536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |