Submission #2561308


Source Code Expand

#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MOD = 1000000007;
const int MAXN = 100005;
const int MAXX = 2005;

int d[MAXX*2][MAXX*2];
ll fac[MAXX*8], invfac[MAXX*8];

int A[MAXN], B[MAXN];

int N, Ans;

ll pw(ll n, ll k) {
	ll r = 1; for(n %= MOD; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}

int main() {
	ios::sync_with_stdio(false);

	fac[0] = 1; for(int i = 1; i < MAXX*8; i++) fac[i] = fac[i-1] * i % MOD;
	invfac[MAXX*8-1] = pw(fac[MAXX*8-1], MOD-2);
	for(int i = MAXX*8-1; i; i--) invfac[i-1] = invfac[i] * i % MOD;
	
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		d[-A[i]+MAXX][-B[i]+MAXX]++;
	}
	for(int i = 1; i < MAXX*2; i++) for(int j = 1; j < MAXX*2; j++)
		d[i][j] = (d[i][j] + (d[i-1][j] + d[i][j-1]) % MOD) % MOD;
	
	for(int i = 0; i < N; i++) {
		Ans = (Ans + d[A[i]+MAXX][B[i]+MAXX]) % MOD;
		Ans = (Ans - fac[A[i]*2+B[i]*2] * invfac[A[i]*2] % MOD * invfac[B[i]*2] % MOD + MOD) % MOD;
	}

	Ans = (ll)Ans * pw(2, MOD-2) % MOD;
	
	cout << Ans << endl;
	return 0;
}

Submission Info

Submission Time
Task E - BBQ Hard
User youngyojun
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2902 Byte
Status RE
Exec Time 319 ms
Memory 64128 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 1
AC × 6
RE × 10
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 162 ms 63360 KB
01-02.txt AC 163 ms 63360 KB
01-03.txt AC 183 ms 64128 KB
01-04.txt RE 319 ms 64128 KB
01-05.txt RE 301 ms 64128 KB
01-06.txt RE 288 ms 64128 KB
01-07.txt AC 163 ms 63360 KB
01-08.txt RE 283 ms 64128 KB
01-09.txt RE 288 ms 64128 KB
01-10.txt RE 292 ms 64128 KB
01-11.txt RE 290 ms 64128 KB
01-12.txt RE 289 ms 64128 KB
01-13.txt RE 299 ms 64128 KB
01-14.txt RE 298 ms 64128 KB
sample-01.txt AC 162 ms 63360 KB