# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
76729 | kdh9949 | 마스코트 (JOI13_mascots) | C++17 | 120 ms | 93304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3005;
const ll M = ll(1e9) + 7;
int h, w, n, a, b, c, d, p[2 * N][2 * N];
ll r = 1;
int main(){
scanf("%d%d%d%d%d", &h, &w, &n, &a, &b);
c = a; d = b;
for(int x, y, i = 0; i < n - 1; i++){
scanf("%d%d", &x, &y);
tie(a, b) = minmax({a, b, x});
tie(c, d) = minmax({c, d, y});
}
for(int i = 1; i <= (b - a + 1) * (d - c + 1) - n; i++) r = r * i % M;
a = a - 1; c = c - 1;
b = h - b; d = w - d;
for(int i = 0; i < 2 * N; i++){
p[i][0] = 1;
for(int j = 1; j <= i; j++) p[i][j] = (p[i - 1][j - 1] + p[i - 1][j]) % M;
}
printf("%lld\n", r * p[a + b + c + d][a + b] % M * p[a + b][a] % M * p[c + d][c] % M);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |