Submission #1866068


Source Code Expand

#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7,bas = 2500;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n;

int A[maxn],B[maxn];

int dp[5010][5010];

int fac[8010],inv[8010];

void Work(){
	REP(i,-2000,2000)
		REP(j,-2000,2000)dp[i+bas][j+bas]=(dp[i-1+bas][j+bas]+dp[i+bas][j-1+bas]+dp[i+bas][j+bas])%mod;
	int ans=0;
	REP(i,1,n)ans=(ans+dp[A[i]+bas][B[i]+bas])%mod;
	REP(i,1,n)ans=(ans-1ll*fac[A[i]+A[i]+B[i]+B[i]]*inv[A[i]+A[i]]%mod*inv[B[i]+B[i]]%mod+mod)%mod;
	ans=1ll*ans*fexp(2,mod-2)%mod;
	iout(ans);
}

void Init(){
	read(n);
	REP(i,1,n)read(A[i],B[i]),dp[bas-A[i]][bas-B[i]]++;
	fac[0]=1;REP(i,1,8000)fac[i]=1ll*fac[i-1]*i%mod;
	REP(i,0,8000)inv[i]=fexp(fac[i],mod-2);
}

int main(){
	Init();
	Work();
	return 0;
}

Submission Info

Submission Time
Task E - BBQ Hard
User yanQval
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 2291 Byte
Status AC
Exec Time 142 ms
Memory 85632 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 1
AC × 16
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 116 ms 84224 KB
01-02.txt AC 116 ms 84224 KB
01-03.txt AC 129 ms 84864 KB
01-04.txt AC 141 ms 85632 KB
01-05.txt AC 142 ms 85632 KB
01-06.txt AC 133 ms 85632 KB
01-07.txt AC 116 ms 84224 KB
01-08.txt AC 125 ms 85632 KB
01-09.txt AC 134 ms 85632 KB
01-10.txt AC 134 ms 85632 KB
01-11.txt AC 135 ms 85632 KB
01-12.txt AC 134 ms 85632 KB
01-13.txt AC 142 ms 85632 KB
01-14.txt AC 142 ms 85632 KB
sample-01.txt AC 116 ms 84224 KB