Submission #2117459


Source Code Expand

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;


long long factorical(int n)
{
  long long ans=1,i;
  for(i=n;i>1;i--)
    ans=(ans*i)%MOD;
  return ans;
}

long long beki(long long a,int n)
{
  long long s=1LL;
  while(n){
    if(n%2)s=(s*a)%MOD;
    a=(a*a)%MOD;
    n/=2;
  }
  return s;
}

long long ncr(int n,int r)
{
  long long a=factorical(n);
  long long b=(factorical(r)*factorical(n-r))%MOD;
  return (a*beki(b,MOD-2))%MOD;
}



signed main(void) {
  int i,j;
  int r,c;
  cin>>r>>c;
  int x,y,d,l;
  cin>>x>>y>>d>>l;
  int ans=((r-x+1)*(c-y+1))%MOD;
  ans=(ans*ncr(d+l,d))%MOD;

  int tmp=ncr(x*y,d+l);

  int tmp1=0;
  if((x-1)*y>d+l)tmp1+=2*ncr((x-1)*y,d+l);
  if(x*(y-1)>d+l)tmp1+=2*ncr(x*(y-1),d+l);
  tmp1%=MOD;
  int tmp2=0;
  if((x-1)*(y-1)>d+l)tmp2=4*ncr((x-1)*(y-1),d+l);
  tmp2%=MOD;
  int tmp3=0;
  if((x-2)*(y-1)>d+l)tmp3+=2*ncr((x-2)*(y-1),d+l);
  if((x-1)*(y-2)>d+l)tmp3+=2*ncr((x-1)*(y-2),d+l);
  tmp3%=MOD;
  int tmp4=0;
  if((x-2)*(y-2)>d+l)tmp4+=ncr((x-2)*(y-2),d+l);
  tmp4%=MOD;

  tmp=(tmp-(tmp1-tmp2+tmp3-tmp4)+MOD)%MOD;

  cout<<(ans*tmp)%MOD<<endl;
}

Submission Info

Submission Time
Task D - AtCoder社の冬
User rika0384
Language Bash (GNU bash v4.3.11)
Score 0
Code Size 1753 Byte
Status RE
Exec Time 3 ms
Memory 588 KB

Judge Result

Set Name sub All
Score / Max Score 0 / 100 0 / 1
Status
RE × 25
RE × 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 RE 3 ms 584 KB
00_sample_02E.txt RE 3 ms 576 KB
00_sample_03E.txt RE 3 ms 576 KB
00_sample_04.txt RE 3 ms 580 KB
test_01.txt RE 3 ms 584 KB
test_02.txt RE 3 ms 588 KB
test_03E.txt RE 3 ms 580 KB
test_04E.txt RE 3 ms 580 KB
test_05.txt RE 3 ms 580 KB
test_06.txt RE 3 ms 580 KB
test_07E.txt RE 3 ms 576 KB
test_08E.txt RE 3 ms 584 KB
test_09.txt RE 3 ms 576 KB
test_10.txt RE 3 ms 576 KB
test_11E.txt RE 3 ms 576 KB
test_12E.txt RE 3 ms 580 KB
test_13.txt RE 3 ms 576 KB
test_14.txt RE 3 ms 576 KB
test_15E.txt RE 3 ms 588 KB
test_16E.txt RE 3 ms 572 KB
test_17.txt RE 3 ms 588 KB
test_18.txt RE 3 ms 576 KB
test_19E.txt RE 3 ms 580 KB
test_20E.txt RE 3 ms 588 KB
test_21.txt RE 3 ms 588 KB
test_22.txt RE 3 ms 576 KB
test_23E.txt RE 3 ms 584 KB
test_24E.txt RE 3 ms 588 KB
test_25.txt RE 3 ms 580 KB
test_26.txt RE 3 ms 584 KB
test_27E.txt RE 3 ms 576 KB
test_28E.txt RE 3 ms 576 KB
test_29.txt RE 3 ms 580 KB
test_30.txt RE 3 ms 580 KB
test_31E.txt RE 3 ms 576 KB
test_32E.txt RE 3 ms 576 KB
test_33.txt RE 3 ms 572 KB
test_34.txt RE 3 ms 580 KB
test_35.txt RE 3 ms 580 KB
test_36E.txt RE 3 ms 576 KB
test_37E.txt RE 3 ms 580 KB
test_38E.txt RE 3 ms 580 KB
test_39E.txt RE 3 ms 580 KB
test_40.txt RE 3 ms 576 KB
test_41.txt RE 3 ms 580 KB
test_42.txt RE 3 ms 576 KB
test_43.txt RE 3 ms 588 KB
test_44.txt RE 3 ms 588 KB
test_45E.txt RE 3 ms 580 KB
test_46.txt RE 3 ms 580 KB
test_47E.txt RE 3 ms 580 KB
test_48.txt RE 3 ms 572 KB