Submission #8092275
Source Code Expand
#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];
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 1ll * fc[n] * iv[m] % mod * iv[n - m] % mod;
}
void init() {
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 -= C(a[i] + a[i] + b[i] + b[i], a[i] + a[i]);
}
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 |
0 |
Code Size |
1457 Byte |
Status |
WA |
Exec Time |
2103 ms |
Memory |
1920 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:47: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 |
0 / 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 |
2 ms |
384 KB |
01-02.txt |
WA |
89 ms |
384 KB |
01-03.txt |
TLE |
2103 ms |
1152 KB |
01-04.txt |
TLE |
2103 ms |
1920 KB |
01-05.txt |
TLE |
2103 ms |
1920 KB |
01-06.txt |
TLE |
2103 ms |
1920 KB |
01-07.txt |
AC |
2 ms |
384 KB |
01-08.txt |
AC |
59 ms |
1920 KB |
01-09.txt |
TLE |
2103 ms |
1920 KB |
01-10.txt |
TLE |
2103 ms |
1920 KB |
01-11.txt |
TLE |
2103 ms |
1920 KB |
01-12.txt |
TLE |
2103 ms |
1920 KB |
01-13.txt |
TLE |
2103 ms |
1920 KB |
01-14.txt |
TLE |
2103 ms |
1920 KB |
sample-01.txt |
AC |
2 ms |
384 KB |