Contest Duration: ~ (local time) (120 minutes) Back to Home

Submission #601512

Source Code Expand

Copy
```#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define MODN 1000000007

ll memo[901][901];
ll combi(ll a, ll b) {
/* if (a < (b<<1)) b = a-b; */
if (a <= 0) return 0;
if (b == 0) return 1;
if (memo[a][b]) return memo[a][b];
if (b == 1) return a;
if (a == b) return 1;
return memo[a][b]=(combi(a-1, b-1)+combi(a-1, b))%MODN;
}

ll patternDL(ll d, ll l, ll x, ll y) {
if (d+l == x*y) return 1;
if (d+l == 1) return 1;
if (d+l == 2) {
if (x > 1 && y > 1) return 2;
return 1;
}
if (d+l == 3) {
if (x > 1 && y > 1) return 2*combi(x*y-4, d+l-2)+4+((x-2)*(y-2))*4+(y-2)*2+(x-2)*2;
return combi(x*y-2, d+l-2);
}
if (x > 1 && y > 1) {
ll kadoP = (2*combi(x*y-4, d+l-2)+4*combi(x*y-4, d+l-3)+combi(x*y-4, d+l-4))%MODN;;
ll hen1 = 0, hen2 = 0, hen3 = 0, hen4 = 0;
for (ll i = 0; i <= y-3; i++) {
hen1 += combi(x*y-5-i, d+l-3);
hen1 %= MODN;
}
hen1 = (hen1*2)%MODN;
for (ll i = 0; i <= x-3; i++) {
hen2 += combi(x*y-5-i, d+l-3);
hen2 %= MODN;
}
hen2 = (hen2*2)%MODN;
for (ll i = 0; i <= x-3; i++) {
for (ll j = 0; j <= y-3; j++) {
hen3 += combi(x*y-6-i-j, d+l-3);
hen3 %= MODN;
}
}
hen3 = (hen3*4)%MODN;
for (ll v1 = 0; v1 <= x-3; v1++) {
for (ll v2 = 0; v2 <= x-3; v2++) {
// for (ll v3 = 0; v3 <= y-3; v3++) {
//   for (ll v4 = 0; v4 <= y-3; v4++) {
//     hen4 += combi(x*y-8-v1-v2-v3-v4, d+l-4);
//     hen4 %= MODN;
//   }
// }
for (ll a = 1; a <= y-3+1; a++) {
hen4 += a*combi(x*y-8-v1-v2-(a-1), d+l-4);
hen4 %= MODN;
}
for (ll a = y-3, b = y-3+1; a >= 1; a--, b++) {
hen4 += a*combi(x*y-8-v1-v2-b, d+l-4);
hen4 %= MODN;
}
}
}
}
return combi(x*y-2, d+l-2);
}

ll patternXY(ll x, ll y, ll r, ll c) {
return (r-x+1)*(c-y+1);
}

int main() {
ll r, c;
ll x, y;
ll d, l;
cin >> r >> c;
cin >> x >> y;
cin >> d >> l;

ll ans = ((patternDL(d, l, x, y)*combi(d+l, d))%MODN)*patternXY(x, y, r, c);
cout << ans%MODN << endl;
}
```

#### Submission Info

Submission Time 2015-12-29 00:11:04+0900 D - AtCoder社の冬 warm4C0 C++11 (GCC 4.8.1) 100 2270 Byte WA 2038 ms 5880 KB

#### Test Cases

Set Name Score / Max Score Test Cases
sub 100 / 100 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, test_03E.txt, test_04E.txt, test_07E.txt, test_08E.txt, test_11E.txt, test_12E.txt, test_15E.txt, test_16E.txt, test_19E.txt, test_20E.txt, test_23E.txt, test_24E.txt, test_27E.txt, test_28E.txt, test_31E.txt, test_32E.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_45E.txt, test_47E.txt
All 0 / 1 00_sample_01E.txt, 00_sample_02E.txt, 00_sample_03E.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03E.txt, test_04E.txt, test_05.txt, test_06.txt, test_07E.txt, test_08E.txt, test_09.txt, test_10.txt, test_11E.txt, test_12E.txt, test_13.txt, test_14.txt, test_15E.txt, test_16E.txt, test_17.txt, test_18.txt, test_19E.txt, test_20E.txt, test_21.txt, test_22.txt, test_23E.txt, test_24E.txt, test_25.txt, test_26.txt, test_27E.txt, test_28E.txt, test_29.txt, test_30.txt, test_31E.txt, test_32E.txt, test_33.txt, test_34.txt, test_35.txt, test_36E.txt, test_37E.txt, test_38E.txt, test_39E.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45E.txt, test_46.txt, test_47E.txt, test_48.txt
Case Name Status Exec Time Memory
00_sample_01E.txt 98 ms 1064 KB
00_sample_02E.txt 30 ms 956 KB
00_sample_03E.txt 33 ms 1848 KB
00_sample_04.txt 40 ms 3632 KB
test_01.txt 2037 ms 1224 KB
test_02.txt 30 ms 956 KB
test_03E.txt 30 ms 956 KB
test_04E.txt 29 ms 956 KB
test_05.txt 29 ms 1076 KB
test_06.txt 41 ms 4016 KB
test_07E.txt 31 ms 952 KB
test_08E.txt 29 ms 952 KB
test_09.txt 33 ms 2108 KB
test_10.txt 38 ms 3144 KB
test_11E.txt 30 ms 956 KB
test_12E.txt 30 ms 980 KB
test_13.txt 30 ms 1328 KB
test_14.txt 2038 ms 4920 KB
test_15E.txt 32 ms 1012 KB
test_16E.txt 29 ms 952 KB
test_17.txt 31 ms 1012 KB
test_18.txt 30 ms 1340 KB
test_19E.txt 29 ms 1024 KB
test_20E.txt 30 ms 1144 KB
test_21.txt 2037 ms 1412 KB
test_22.txt 44 ms 3424 KB
test_23E.txt 30 ms 952 KB
test_24E.txt 33 ms 956 KB
test_25.txt 2036 ms 1744 KB
test_26.txt 31 ms 1208 KB
test_27E.txt 31 ms 1008 KB
test_28E.txt 30 ms 1016 KB
test_29.txt 48 ms 5100 KB
test_30.txt 54 ms 5880 KB
test_31E.txt 31 ms 1016 KB
test_32E.txt 31 ms 968 KB
test_33.txt 31 ms 1088 KB
test_34.txt 2037 ms 1576 KB
test_35.txt 31 ms 1016 KB
test_36E.txt 30 ms 1020 KB
test_37E.txt 29 ms 1140 KB
test_38E.txt 29 ms 1024 KB
test_39E.txt 29 ms 1020 KB
test_40.txt 31 ms 1464 KB
test_41.txt 27 ms 944 KB
test_42.txt 30 ms 1392 KB
test_43.txt 31 ms 1092 KB
test_44.txt 30 ms 1464 KB
test_45E.txt 29 ms 1000 KB
test_46.txt 29 ms 1080 KB
test_47E.txt 28 ms 1076 KB
test_48.txt 27 ms 1148 KB