Submission #8515308


Source Code Expand

Copy
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

D = 2000

U = 10 ** 4
fact = [1] * U
for n in range(1,U):
    fact[n] = fact[n-1] * n % MOD
fact_inv = [1] * U
fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for n in range(U-1,0,-1):
    fact_inv[n-1] = fact_inv[n] * n % MOD

C_to_A = [[] for _ in range(D+D+1)]
Y = 0
for a,b in AB:
    c = a+b
    C_to_A[c].append(D-a)
    Y += fact[c+c] * fact_inv[a+a] * fact_inv[b+b]
Y %= MOD

f = np.zeros(D+D+1,np.int64)
for A in C_to_A[::-1]:
    f[1:] += f[:-1].copy()
    np.add.at(f,A,1)
    f %= MOD
X = (f * f[::-1] % MOD).sum() % MOD

answer = (X - Y) * fact_inv[2] % MOD
print(answer)

Submission Info

Submission Time
Task E - BBQ Hard
User maspy
Language Python (3.4.3)
Score 1400
Code Size 834 Byte
Status AC
Exec Time 761 ms
Memory 40384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 1
AC × 16
Set Name Test Cases
Sample sample-01.txt
All sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, sample-01.txt
Case Name Status Exec Time Memory
01-01.txt AC 432 ms 13036 KB
01-02.txt AC 432 ms 13288 KB
01-03.txt AC 593 ms 26280 KB
01-04.txt AC 750 ms 39524 KB
01-05.txt AC 748 ms 39520 KB
01-06.txt AC 703 ms 34592 KB
01-07.txt AC 435 ms 13160 KB
01-08.txt AC 668 ms 25504 KB
01-09.txt AC 702 ms 40384 KB
01-10.txt AC 724 ms 37772 KB
01-11.txt AC 739 ms 38672 KB
01-12.txt AC 710 ms 35136 KB
01-13.txt AC 746 ms 39532 KB
01-14.txt AC 761 ms 39480 KB
sample-01.txt AC 431 ms 13156 KB