Submission #3417337
Source Code Expand
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 2e5 + 10;
const int M = 4005;
const int mod = 1e9 + 7;
int n, m, a[N], b[N];
LL inv[M << 1], fac[M << 1], fav[M << 1], dp[M][M];
void init() {
fac[0] = fav[0] = 1;
inv[1] = fac[1] = fav[1] = 1;
for (int i = 2; i < M << 1; ++i) {
inv[i] = -mod / i * inv[mod % i] % mod + mod;
fac[i] = fac[i - 1] * i % mod;
fav[i] = fav[i - 1] * inv[i] % mod;
}
}
inline void Add(LL &x, LL y) {
x += y;
if (x >= mod) x -= mod;
}
inline LL C(int x, int y) {
if (x < 0 || x < y) return 0;
return fac[x] * fav[y] % mod * fav[x - y] % mod;
}
int main() {
init();
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
scanf("%d%d", &a[i], &b[i]);
dp[-a[i] + 2001][-b[i] + 2001]++;
}
for (int i = 1; i < M - 1; ++i) {
for (int j = 1; j < M - 1; ++j) {
Add(dp[i][j + 1], dp[i][j]);
Add(dp[i + 1][j], dp[i][j]);
}
}
LL ans = 0;
for (int i = 1; i <= n; ++i) {
Add(ans, dp[a[i] + 2001][b[i] + 2001]);
ans -= C(a[i] * 2 + b[i] * 2, a[i] * 2);
if (ans < 0) ans += mod;
}
cout << ans * (mod + 1) / 2 % mod << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - BBQ Hard |
User |
Vexoben |
Language |
C++14 (GCC 5.4.1) |
Score |
1400 |
Code Size |
1172 Byte |
Status |
AC |
Exec Time |
151 ms |
Memory |
127232 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:33:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:35:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a[i], &b[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
1400 / 1400 |
Status |
|
|
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 |
88 ms |
127232 KB |
01-02.txt |
AC |
102 ms |
127232 KB |
01-03.txt |
AC |
126 ms |
127232 KB |
01-04.txt |
AC |
151 ms |
127232 KB |
01-05.txt |
AC |
150 ms |
127232 KB |
01-06.txt |
AC |
134 ms |
127232 KB |
01-07.txt |
AC |
75 ms |
127232 KB |
01-08.txt |
AC |
101 ms |
127232 KB |
01-09.txt |
AC |
120 ms |
127232 KB |
01-10.txt |
AC |
141 ms |
127232 KB |
01-11.txt |
AC |
142 ms |
127232 KB |
01-12.txt |
AC |
137 ms |
127232 KB |
01-13.txt |
AC |
150 ms |
127232 KB |
01-14.txt |
AC |
150 ms |
127232 KB |
sample-01.txt |
AC |
75 ms |
127232 KB |