Submission #1099830


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

int ans, N, M, mod = 1e9 + 7, a[200009], b[200009], fac[8009], inv[8009], dp[4009][4009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = pow (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N), Prec (8000), M = 2000, ans = 0;
for (int i=1; i<=N; i++)
{
    scanf ("%d %d", &a[i], &b[i]), dp[M + 1 - a[i]][M + 1 - b[i]] ++;
    ans = substract (ans, comb (2 * a[i] + 2 * b[i], 2 * a[i]));
}
for (int i=1; i<=2 * M + 1; i++)
    for (int j=1; j<=2 * M + 1; j++)
        dp[i][j] = add (dp[i][j], add (dp[i - 1][j], dp[i][j - 1]));
for (int i=1; i<=N; i++)
    ans = add (ans, dp[M + 1 + a[i]][M + 1 + b[i]]);
ans = mul (ans, pow (2, mod - 2));
printf ("%d\n", ans);
return 0;
}

Submission Info

Submission Time
Task E - BBQ Hard
User geniucos
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 1441 Byte
Status AC
Exec Time 230 ms
Memory 64512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 scanf ("%d", &N), Prec (8000), M = 2000, ans = 0;
                                                 ^
./Main.cpp:34:69: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &a[i], &b[i]), dp[M + 1 - a[i]][M + 1 - b[i]] ++;
                                                                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1400 / 1400
Status
AC × 1
AC × 15
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
Case Name Status Exec Time Memory
01-01.txt AC 190 ms 62976 KB
01-02.txt AC 188 ms 62976 KB
01-03.txt AC 196 ms 63744 KB
01-04.txt AC 219 ms 64512 KB
01-05.txt AC 219 ms 64512 KB
01-06.txt AC 228 ms 64512 KB
01-07.txt AC 190 ms 62976 KB
01-08.txt AC 223 ms 64512 KB
01-09.txt AC 230 ms 64512 KB
01-10.txt AC 224 ms 64512 KB
01-11.txt AC 227 ms 64512 KB
01-12.txt AC 229 ms 64512 KB
01-13.txt AC 222 ms 64512 KB
01-14.txt AC 219 ms 64512 KB
sample-01.txt AC 191 ms 62976 KB