Submission #123856


Source Code Expand

Copy
import sys

mo = 1000000007
R,C=map(int,raw_input().strip().split(" "))
X,Y=map(int,raw_input().strip().split(" "))
D,L=map(int,raw_input().strip().split(" "))

co=[[0 for i in range(1000)] for j in range(1000)]

for x in range(1000):
	co[x][x]=1

for x in range(1,1000):
	for y in range(0,x+1):
		co[x][y] = (co[x-1][y-1] + co[x-1][y]) % mo

ret = 0
for i in range(16):
	xx=X
	yy=Y
	pa=0
	if i & 1:
		xx-=1
		pa+=1
	if i & 2:
		xx-=1
		pa+=1
	if i & 4:
		yy-=1
		pa+=1
	if i & 8:
		yy-=1
		pa+=1
	if xx>=0 and yy>=0 and xx*yy>=D+L:
		if pa % 2 == 0:
			ret += co[xx*yy][D+L]
		else:
			ret -= co[xx*yy][D+L]

ret = ((ret%mo)+mo)%mo
ret = ret * (R-X+1) * (C-Y+1) * co[D+L][L] % mo
print ret


Submission Info

Submission Time
Task D - AtCoder社の冬
User kmjp
Language Python (2.7.3)
Score 101
Code Size 737 Byte
Status
Exec Time 706 ms
Memory 24384 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 1 / 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 638 ms 24368 KB
00_sample_02E.txt 632 ms 24364 KB
00_sample_03E.txt 645 ms 24364 KB
00_sample_04.txt 673 ms 24372 KB
test_01.txt 645 ms 24364 KB
test_02.txt 642 ms 24312 KB
test_03E.txt 634 ms 24360 KB
test_04E.txt 641 ms 24360 KB
test_05.txt 634 ms 24312 KB
test_06.txt 637 ms 24360 KB
test_07E.txt 637 ms 24372 KB
test_08E.txt 639 ms 24360 KB
test_09.txt 646 ms 24364 KB
test_10.txt 632 ms 24368 KB
test_11E.txt 640 ms 24288 KB
test_12E.txt 648 ms 24356 KB
test_13.txt 634 ms 24360 KB
test_14.txt 640 ms 24364 KB
test_15E.txt 642 ms 24360 KB
test_16E.txt 706 ms 24296 KB
test_17.txt 633 ms 24364 KB
test_18.txt 640 ms 24356 KB
test_19E.txt 644 ms 24352 KB
test_20E.txt 642 ms 24292 KB
test_21.txt 638 ms 24368 KB
test_22.txt 631 ms 24368 KB
test_23E.txt 632 ms 24384 KB
test_24E.txt 642 ms 24364 KB
test_25.txt 633 ms 24296 KB
test_26.txt 643 ms 24364 KB
test_27E.txt 637 ms 24360 KB
test_28E.txt 634 ms 24312 KB
test_29.txt 636 ms 24360 KB
test_30.txt 635 ms 24364 KB
test_31E.txt 637 ms 24352 KB
test_32E.txt 636 ms 24364 KB
test_33.txt 638 ms 24356 KB
test_34.txt 649 ms 24312 KB
test_35.txt 657 ms 24368 KB
test_36E.txt 636 ms 24308 KB
test_37E.txt 637 ms 24352 KB
test_38E.txt 637 ms 24296 KB
test_39E.txt 645 ms 24368 KB
test_40.txt 628 ms 24368 KB
test_41.txt 629 ms 24368 KB
test_42.txt 625 ms 24316 KB
test_43.txt 646 ms 24368 KB
test_44.txt 648 ms 24364 KB
test_45E.txt 654 ms 24372 KB
test_46.txt 641 ms 24372 KB
test_47E.txt 645 ms 24364 KB
test_48.txt 633 ms 24356 KB