Submission #2106827
Source Code Expand
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
char ch,fu=0;
for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
if(ch=='-') fu=1, ch=getchar();
for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
if(fu) v=-v;
}
const int MO=1e9+7;
LL ans,fac[4010],inv[4010];
int n,v[4010][4010],tag[4010][4010],a[200010],b[200010];
LL pw(LL x,LL y){
LL t=1;
for (;y;y>>=1){
if (y&1) t=t*x%MO;
x=x*x%MO;
}
return t;
}
LL C(int x,int y){
return fac[x]*inv[y]%MO*inv[x-y]%MO;
}
int main(){
scanf("%d",&n);
FOR(i,1,n){
scanf("%d%d",&a[i],&b[i]);
v[2000-a[i]][2000-b[i]]++;
tag[2000+a[i]][2000+b[i]]++;
}
FOR(i,0,4000)
FOR(j,0,4000){
(v[i+1][j]+=v[i][j])%=MO;
(v[i][j+1]+=v[i][j])%=MO;
}
FOR(i,0,4000)
FOR(j,0,4000)
(ans+=1ll*v[i][j]*tag[i][j])%=MO;
fac[0]=1;
FOR(i,1,8000) fac[i]=fac[i-1]*i%MO;
inv[8000]=pw(fac[8000],MO-2);
FORD(i,7999,0) inv[i]=inv[i+1]*(i+1)%MO;
FOR(i,1,n)
(ans-=C(a[i]+a[i]+b[i]+b[i],a[i]+a[i]))%=MO;
ans=ans*pw(2,MO-2)%MO;
ans=(ans%MO+MO)%MO;
cout<<ans<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - BBQ Hard |
User |
cwystc |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1522 Byte |
Status |
RE |
Exec Time |
324 ms |
Memory |
96128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:44:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:46:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&a[i],&b[i]);
^
./Main.cpp:59:30: warning: iteration 4010u invokes undefined behavior [-Waggressive-loop-optimizations]
FOR(i,1,8000) fac[i]=fac[i-1]*i%MO;
^
./Main.cpp:18:34: note: containing loop
#define FOR(i,a,b) for (int i=a;i<=b;i++)
^
./Main.cpp:59:2: note: in expansion of macro ‘FOR’
FOR(i,1,8000) fac[i]=fac[i-1]*i%MO;
^
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 |
283 ms |
65920 KB |
01-02.txt |
RE |
276 ms |
94592 KB |
01-03.txt |
RE |
299 ms |
95360 KB |
01-04.txt |
RE |
321 ms |
96128 KB |
01-05.txt |
RE |
324 ms |
96128 KB |
01-06.txt |
RE |
300 ms |
65408 KB |
01-07.txt |
RE |
270 ms |
65920 KB |
01-08.txt |
RE |
296 ms |
67456 KB |
01-09.txt |
RE |
302 ms |
67456 KB |
01-10.txt |
RE |
310 ms |
81792 KB |
01-11.txt |
RE |
310 ms |
81792 KB |
01-12.txt |
RE |
304 ms |
71552 KB |
01-13.txt |
RE |
322 ms |
96128 KB |
01-14.txt |
RE |
322 ms |
96128 KB |
sample-01.txt |
RE |
271 ms |
65920 KB |