Submission #8092296
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, CC[4005][4005];
int F[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];
}
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]);
}
}
}
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 - C(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 |
0 |
Code Size |
1401 Byte |
Status |
RE |
Exec Time |
153 ms |
Memory |
63104 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:49:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:50: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 |
RE |
120 ms |
62208 KB |
01-02.txt |
RE |
122 ms |
62208 KB |
01-03.txt |
RE |
136 ms |
62592 KB |
01-04.txt |
RE |
150 ms |
63104 KB |
01-05.txt |
RE |
150 ms |
63104 KB |
01-06.txt |
RE |
149 ms |
63104 KB |
01-07.txt |
AC |
24 ms |
62208 KB |
01-08.txt |
AC |
52 ms |
63104 KB |
01-09.txt |
RE |
151 ms |
63104 KB |
01-10.txt |
RE |
149 ms |
62976 KB |
01-11.txt |
RE |
150 ms |
63104 KB |
01-12.txt |
RE |
153 ms |
63104 KB |
01-13.txt |
RE |
150 ms |
63104 KB |
01-14.txt |
RE |
150 ms |
63104 KB |
sample-01.txt |
AC |
24 ms |
62208 KB |