Submission #8815664


Source Code Expand

#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 2010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll X[200001], Y[200001];
int dp[MAXN*2][MAXN*2];
int C[MAXN*4][MAXN*2];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n;
	for (int i=1; i<=n; i++) cin>>X[i]>>Y[i], dp[MAXN-X[i]][MAXN-Y[i]]++;
	for (int i=1; i<MAXN*2; i++) for (int j=1; j<MAXN*2; j++) dp[i][j]=(dp[i][j] + dp[i-1][j] + dp[i][j-1])%mod;
	for (int i=0; i<MAXN*4; i++){
		C[i][0]=C[i][i]=1;
		for (int j=1; j<min(i, MAXN*2); j++) C[i][j]=(C[i-1][j] + C[i-1][j-1])%mod;
	}
	for (int i=1; i<=n; i++){
		ans=(ans + dp[MAXN+X[i]][MAXN+Y[i]])%mod;
		ans=(ans - C[X[i]*2+Y[i]*2][X[i]*2])%mod;
	}
	ans=ans*(mod+1)/2%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
		
	return 0;
}

Submission Info

Submission Time
Task E - BBQ Hard
User alishahali1382
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 1634 Byte
Status AC
Exec Time 213 ms
Memory 191232 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:20: warning: iteration 4019u invokes undefined behavior [-Waggressive-loop-optimizations]
   C[i][0]=C[i][i]=1;
                    ^
./Main.cpp:38:17: note: containing loop
  for (int i=0; i<MAXN*4; i++){
                 ^

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 164 ms 191232 KB
01-02.txt AC 165 ms 191232 KB
01-03.txt AC 189 ms 191232 KB
01-04.txt AC 207 ms 191232 KB
01-05.txt AC 211 ms 191232 KB
01-06.txt AC 193 ms 191232 KB
01-07.txt AC 164 ms 191232 KB
01-08.txt AC 186 ms 191232 KB
01-09.txt AC 193 ms 191232 KB
01-10.txt AC 199 ms 191232 KB
01-11.txt AC 203 ms 191232 KB
01-12.txt AC 196 ms 191232 KB
01-13.txt AC 213 ms 191232 KB
01-14.txt AC 213 ms 191232 KB
sample-01.txt AC 164 ms 191232 KB