Submission #212813


Source Code Expand

#include <bitset>
#include <iostream>
using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
ll pas[900][900];

ll bi(const int x, const int y) {
  if (x < y) return 0;
  if (pas[x-y][y]) return pas[x-y][y];
  for (int i=0; i<=x-y; i++) {
    for (int j=0; j<=y; j++) {
      if (!i || !j) pas[i][j] = 1;
      else pas[i][j] = (pas[i][j-1] + pas[i-1][j]) % MOD;
    }
  }
  return pas[x-y][y];
}

int main() {
  int R, C, X, Y, D, L;
  cin >> R >> C >> X >> Y >> D >> L;
  ll dl = bi(X*Y,D) * bi(X*Y-D,L);
  for (int f=1; f<1<<4; f++) {
    int x = X, y = Y;
    bitset<5> fb(f);
    if (fb[0]) x--;
    if (fb[1]) x--;
    if (fb[2]) y--;
    if (fb[3]) y--;
    if (x <= 0 || y <= 0) continue;
    if (fb.count() % 2)
      dl -= bi(x*y,D) * bi(x*y-D,L);
    else
      dl += bi(x*y,D) * bi(x*y-D,L);
  }
  dl = (dl%MOD + MOD) % MOD;
  int space = (C-Y+1)*(R-X+1);
  ll res = (dl * space) % MOD;
  cout << res << endl;
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User hark
Language C++ (G++ 4.6.4)
Score 101
Code Size 982 Byte
Status AC
Exec Time 30 ms
Memory 5672 KB

Judge Result

Set Name sub All
Score / Max Score 100 / 100 1 / 1
Status
AC × 25
AC × 52
Set Name Test Cases
sub 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 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 AC 21 ms 804 KB
00_sample_02E.txt AC 21 ms 924 KB
00_sample_03E.txt AC 22 ms 1188 KB
00_sample_04.txt AC 24 ms 2724 KB
test_01.txt AC 21 ms 1060 KB
test_02.txt AC 22 ms 800 KB
test_03E.txt AC 21 ms 932 KB
test_04E.txt AC 22 ms 2340 KB
test_05.txt AC 20 ms 800 KB
test_06.txt AC 25 ms 3872 KB
test_07E.txt AC 20 ms 1056 KB
test_08E.txt AC 21 ms 1692 KB
test_09.txt AC 24 ms 1956 KB
test_10.txt AC 23 ms 3108 KB
test_11E.txt AC 22 ms 1572 KB
test_12E.txt AC 23 ms 2216 KB
test_13.txt AC 21 ms 1184 KB
test_14.txt AC 28 ms 4384 KB
test_15E.txt AC 23 ms 2600 KB
test_16E.txt AC 26 ms 4380 KB
test_17.txt AC 22 ms 932 KB
test_18.txt AC 22 ms 1056 KB
test_19E.txt AC 20 ms 804 KB
test_20E.txt AC 20 ms 932 KB
test_21.txt AC 21 ms 1176 KB
test_22.txt AC 25 ms 3100 KB
test_23E.txt AC 21 ms 808 KB
test_24E.txt AC 26 ms 3364 KB
test_25.txt AC 22 ms 1312 KB
test_26.txt AC 21 ms 936 KB
test_27E.txt AC 23 ms 2336 KB
test_28E.txt AC 24 ms 2848 KB
test_29.txt AC 27 ms 4772 KB
test_30.txt AC 30 ms 5672 KB
test_31E.txt AC 22 ms 1568 KB
test_32E.txt AC 26 ms 4388 KB
test_33.txt AC 21 ms 932 KB
test_34.txt AC 20 ms 800 KB
test_35.txt AC 20 ms 804 KB
test_36E.txt AC 21 ms 932 KB
test_37E.txt AC 21 ms 740 KB
test_38E.txt AC 21 ms 744 KB
test_39E.txt AC 21 ms 804 KB
test_40.txt AC 21 ms 1180 KB
test_41.txt AC 20 ms 928 KB
test_42.txt AC 21 ms 932 KB
test_43.txt AC 21 ms 816 KB
test_44.txt AC 22 ms 1052 KB
test_45E.txt AC 21 ms 796 KB
test_46.txt AC 21 ms 808 KB
test_47E.txt AC 23 ms 800 KB
test_48.txt AC 22 ms 800 KB