求调样例不过
查看原帖
求调样例不过
852144
Loser_Syx楼主2024/7/8 11:55
#include <iostream>
#include <cassert>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <map>
#include <set>
using namespace std;
// #define int long long
#define pii pair<int, int>
#define eb emplace_back
#define F first
#define S second
#define test(x) cout << "Test: " << x << '\n'
#define lowbit(x) (x & -x)
#define debug puts("qwq");
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define close fclose(stdin);fclose(stdout);
namespace FastIO {
	template <typename T = int>
	inline T read() {
		T s = 0, w = 1;
		char c = getchar();
		while (!isdigit(c)) {
			if (c == '-') w = -1;
			c = getchar();
		}
		while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
		return s * w;
	}
	template <typename T>
	inline void read(T &s) {
		s = 0;
		int w = 1;
		char c = getchar();
		while (!isdigit(c)) {
			if (c == '-') w = -1;
			c = getchar();
		}
		while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
		s = s * w;
	}
	template <typename T, typename... Arp> inline void read(T &x, Arp &...arp) {
		read(x), read(arp...);
	}
	template <typename T>
	inline void write(T x, char ch) {
		if (x < 0) x = -x, putchar('-');
		static char stk[25];
		int top = 0;
		do {
			stk[top++] = x % 10 + '0', x /= 10;
		} while (x);
		while (top) putchar(stk[--top]);
		putchar(ch);
		return;
	}
	template <typename T>
	inline void smax(T &x, T y) {
		if (x < y) x = y;
	}
	template <typename T>
	inline void smin(T &x, T y) {
		if (x > y) x = y;
	}
	void quit() {
		exit(0);
	}
} using namespace FastIO;
const int N = 4022, M = 8200, B = 2011, mod = 1e9 + 7;
int mul[M], inv[M], a[B], b[B], dp[N][N];
void add(int &x, int y) { (x += y) %= mod; }
void sub(int &x, int y) { (x = x - y + mod) %= mod; }
int calc(int n, int m) { return 1LL * mul[n] * inv[n - m] % mod * inv[m] % mod; }
int ksm(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = 1LL * res * a % mod;
		b >>= 1;
		a = 1LL * a * a % mod;
	}
	return res;
}
signed main() {
	mul[0] = 1; inv[0] = ksm(1, mod-2);
	for (int i = 1; i < N; ++i) inv[i] = ksm(mul[i] = 1LL * mul[i-1] * i % mod, mod - 2);
	int n = read();
	for (int i = 1; i <= n; ++i) {
		read(a[i], b[i]);
		dp[-a[i] + B][-b[i] + B]++;
	}
	for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		add(ans, dp[a[i] + B][b[i] + B]);
		sub(ans, calc(2 * (a[i] + b[i]), a[i] + a[i]));
	}
	ans = ans * (mod + 1) / 2 % mod;
	write((ans + mod) % mod, '\n');
	return 0;
}
2024/7/8 11:55
加载中...