Submission #8092318


Source Code Expand

#pragma GCC optimize("Ofast")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
int mod = 1000000007;
inline int MOD(int x) {
	return x >= mod ? x - mod : x;
}
int qpow(int a, int b) {
	int as = 1;
	while(b) {
		if(b & 1) as = 1ll * as * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return as;
}
int a[200005], b[200005], CC[4005][4005];
int n, m;
int F[10005], fc[10005], iv[10005], G[10005];
int& f(int x) {
	return F[x + 3000];
}
int& g(int x) {
	return G[x + 3000];
}
int as;
int C(int n, int m) {
	return CC[n][m];
}
int CCC(int n, int m) {
	return 1ll * fc[n] * iv[m] % mod * iv[n - m] % mod;
}
void init() {
	CC[0][0] = 1;
	rep(i, 1, 4000) {
		CC[i][0] = CC[i][i] = 1;
		rop(j, 1, i) {
			CC[i][j] = MOD(CC[i - 1][j - 1] + CC[i - 1][j]);
		}
	}
	fc[0] = iv[0] = 1;
	rep(i, 1, 10000) fc[i] = 1ll * fc[i - 1] * i % mod;
	iv[10000] = qpow(fc[10000], mod - 2);
	per(i, 9999, 1) iv[i] = 1ll * iv[i + 1] * (i + 1) % mod;
}
int main() {
	init();
	scanf("%d", &n);
	rep(i, 1, n) scanf("%d%d", &a[i], &b[i]);
	rep(i, 1, n) {
		rep(j, -b[i], a[i]) {
			f(j) = MOD(f(j) + C(a[i] + b[i], a[i] - j));
		}
		rep(j, -a[i], b[i]) {
			g(j) = MOD(g(j) + C(a[i] + b[i], a[i] + j));
		}
		as = MOD(as - CCC(a[i] + a[i] + b[i] + b[i], a[i] + a[i]) + mod);
	}
	rep(j, -2000, 2000) as = MOD(as + 1ll * f(j) * g(j) % mod);
	cout << 1ll * as * qpow(2, mod - 2) % mod << endl;
	return 0;
}

Submission Info

Submission Time
Task E - BBQ Hard
User Smeow
Language C++ (GCC 5.4.1)
Score 1400
Code Size 1712 Byte
Status AC
Exec Time 648 ms
Memory 63232 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:57:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:58:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i, 1, n) scanf("%d%d", &a[i], &b[i]);
                                          ^

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 17 ms 62336 KB
01-02.txt AC 19 ms 62336 KB
01-03.txt AC 207 ms 62720 KB
01-04.txt AC 397 ms 63232 KB
01-05.txt AC 395 ms 63232 KB
01-06.txt AC 648 ms 63232 KB
01-07.txt AC 17 ms 62336 KB
01-08.txt AC 51 ms 63232 KB
01-09.txt AC 422 ms 63232 KB
01-10.txt AC 534 ms 63104 KB
01-11.txt AC 543 ms 63232 KB
01-12.txt AC 641 ms 63232 KB
01-13.txt AC 399 ms 63232 KB
01-14.txt AC 396 ms 63232 KB
sample-01.txt AC 16 ms 62336 KB