Submission #1383687
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll maxx = 4004, maxn = 2e5 + 20, mod = 1e9 + 7, gaam = 2001; ll dp[maxx][maxx], fac[maxn], a[maxn], b[maxn], n; ll pw(ll a, ll b) { if (!b) return 1ll; ll x = pw(a, b / 2); x = (x * x) % mod; if (b % 2) x = (x * a) % mod; return x; } ll sel(ll a, ll b) { ll x = 1ll; x = (x * fac[a]) % mod; x = (x * pw(fac[b], mod - 2)) % mod; x = (x * pw(fac[a-b], mod - 2)) % mod; return x; } int main() { ios::sync_with_stdio(false); cin.tie(0); fac[0] = 1ll; for(ll i = 1; i < maxn; i++) fac[i] = (fac[i - 1] * 1ll * i) % mod; cin >> n; for(ll i = 0; i < n; i++) cin >> a[i] >> b[i], dp[-a[i] + gaam][-b[i] + gaam] += 1; for(ll i = -gaam; i <= gaam; i++) for(ll j = -gaam; j <= gaam; j++) // if (dp[i + gaam][j + gaam] == 0) dp[i + gaam][j + gaam] = (dp[i + gaam][j + gaam] + ((i + gaam) ? dp[i-1 + gaam][j + gaam] : 0ll) + ((j + gaam) ? dp[i + gaam][j-1 + gaam] : 0ll)) % mod; // cout << i << " " << j << " " << dp[i + gaam][j + gaam] << endl; ll ans = 0; for(ll i = 0; i < n; i++) ans = (ans + dp[a[i] + gaam][b[i] + gaam]) % mod, ans = (((ans - sel(a[i]*2 + b[i]*2, a[i]*2)) % mod) + mod) % mod; ans = (ans * pw(2, mod - 2)) % mod; cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - BBQ Hard |
User | Behnood |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1350 Byte |
Status | AC |
Exec Time | 278 ms |
Memory | 130176 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1400 / 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 | 117 ms | 128128 KB |
01-02.txt | AC | 118 ms | 128128 KB |
01-03.txt | AC | 199 ms | 129408 KB |
01-04.txt | AC | 278 ms | 130176 KB |
01-05.txt | AC | 277 ms | 130176 KB |
01-06.txt | AC | 252 ms | 130176 KB |
01-07.txt | AC | 117 ms | 128128 KB |
01-08.txt | AC | 245 ms | 130176 KB |
01-09.txt | AC | 252 ms | 130176 KB |
01-10.txt | AC | 263 ms | 130176 KB |
01-11.txt | AC | 270 ms | 130176 KB |
01-12.txt | AC | 255 ms | 130176 KB |
01-13.txt | AC | 277 ms | 130176 KB |
01-14.txt | AC | 278 ms | 130176 KB |
sample-01.txt | AC | 117 ms | 128128 KB |