From a97d1c11ac749925bb5f5c233ec9534a6440b288 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 7 Dec 2022 16:16:54 +0800 Subject: [PATCH] E - BBQ Hard https://atcoder.jp/contests/agc001/submissions/37074356 --- AtCoder/AGC001/E/E.cpp | 70 +++++++++++++++++++++++++++++ AtCoder/AGC001/E/data/01-01.in | 3 ++ AtCoder/AGC001/E/data/01-01.out | 3 ++ AtCoder/AGC001/E/data/01-02.in | 3 ++ AtCoder/AGC001/E/data/01-02.out | 3 ++ AtCoder/AGC001/E/data/01-03.in | 3 ++ AtCoder/AGC001/E/data/01-03.out | 3 ++ AtCoder/AGC001/E/data/01-04.in | 3 ++ AtCoder/AGC001/E/data/01-04.out | 3 ++ AtCoder/AGC001/E/data/01-05.in | 3 ++ AtCoder/AGC001/E/data/01-05.out | 3 ++ AtCoder/AGC001/E/data/01-06.in | 3 ++ AtCoder/AGC001/E/data/01-06.out | 3 ++ AtCoder/AGC001/E/data/01-07.in | 3 ++ AtCoder/AGC001/E/data/01-07.out | 3 ++ AtCoder/AGC001/E/data/01-08.in | 3 ++ AtCoder/AGC001/E/data/01-08.out | 3 ++ AtCoder/AGC001/E/data/01-09.in | 3 ++ AtCoder/AGC001/E/data/01-09.out | 3 ++ AtCoder/AGC001/E/data/01-10.in | 3 ++ AtCoder/AGC001/E/data/01-10.out | 3 ++ AtCoder/AGC001/E/data/01-11.in | 3 ++ AtCoder/AGC001/E/data/01-11.out | 3 ++ AtCoder/AGC001/E/data/01-12.in | 3 ++ AtCoder/AGC001/E/data/01-12.out | 3 ++ AtCoder/AGC001/E/data/01-13.in | 3 ++ AtCoder/AGC001/E/data/01-13.out | 3 ++ AtCoder/AGC001/E/data/01-14.in | 3 ++ AtCoder/AGC001/E/data/01-14.out | 3 ++ AtCoder/AGC001/E/data/sample-01.in | 3 ++ AtCoder/AGC001/E/data/sample-01.out | 3 ++ 31 files changed, 160 insertions(+) create mode 100644 AtCoder/AGC001/E/E.cpp create mode 100644 AtCoder/AGC001/E/data/01-01.in create mode 100644 AtCoder/AGC001/E/data/01-01.out create mode 100644 AtCoder/AGC001/E/data/01-02.in create mode 100644 AtCoder/AGC001/E/data/01-02.out create mode 100644 AtCoder/AGC001/E/data/01-03.in create mode 100644 AtCoder/AGC001/E/data/01-03.out create mode 100644 AtCoder/AGC001/E/data/01-04.in create mode 100644 AtCoder/AGC001/E/data/01-04.out create mode 100644 AtCoder/AGC001/E/data/01-05.in create mode 100644 AtCoder/AGC001/E/data/01-05.out create mode 100644 AtCoder/AGC001/E/data/01-06.in create mode 100644 AtCoder/AGC001/E/data/01-06.out create mode 100644 AtCoder/AGC001/E/data/01-07.in create mode 100644 AtCoder/AGC001/E/data/01-07.out create mode 100644 AtCoder/AGC001/E/data/01-08.in create mode 100644 AtCoder/AGC001/E/data/01-08.out create mode 100644 AtCoder/AGC001/E/data/01-09.in create mode 100644 AtCoder/AGC001/E/data/01-09.out create mode 100644 AtCoder/AGC001/E/data/01-10.in create mode 100644 AtCoder/AGC001/E/data/01-10.out create mode 100644 AtCoder/AGC001/E/data/01-11.in create mode 100644 AtCoder/AGC001/E/data/01-11.out create mode 100644 AtCoder/AGC001/E/data/01-12.in create mode 100644 AtCoder/AGC001/E/data/01-12.out create mode 100644 AtCoder/AGC001/E/data/01-13.in create mode 100644 AtCoder/AGC001/E/data/01-13.out create mode 100644 AtCoder/AGC001/E/data/01-14.in create mode 100644 AtCoder/AGC001/E/data/01-14.out create mode 100644 AtCoder/AGC001/E/data/sample-01.in create mode 100644 AtCoder/AGC001/E/data/sample-01.out diff --git a/AtCoder/AGC001/E/E.cpp b/AtCoder/AGC001/E/E.cpp new file mode 100644 index 00000000..e6381854 --- /dev/null +++ b/AtCoder/AGC001/E/E.cpp @@ -0,0 +1,70 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e5 + 5, + M = 2005; +const int mod = 1e9 + 7; + +int n, m, a[N], b[N], inv[M << 2], fac[M << 2], inv_fac[M << 2], _f[M << 1][M << 1], *_pf[M << 1], **f, ans; + +inline int C(int n, int m) { + return static_cast(fac[n]) * inv_fac[m] % mod * inv_fac[n - m] % mod; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + fac[0] = 1; + for (int i = 1; i < M << 2; i++) { + fac[i] = static_cast(fac[i - 1]) * i % mod; + } + + inv[0] = inv[1] = 1; + for (int i = 2; i < M << 2; i++) { + inv[i] = static_cast(mod - (mod / i)) * inv[mod % i] % mod; + } + + inv_fac[0] = inv_fac[1] = 1; + for (int i = 2; i < M << 2; i++) { + inv_fac[i] = static_cast(inv_fac[i - 1]) * inv[i] % mod; + } + + for (int i = 0; i < M << 1; i++) { + _pf[i] = _f[i] + M; + } + + f = _pf + M; + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i] >> b[i]; + + f[-a[i]][-b[i]]++; + } + + for (int i = -2000; i <= 2000; i++) { + for (int j = -2000; j <= 2000; j++) { + f[i][j] = (static_cast(f[i][j]) + f[i - 1][j] + f[i][j - 1]) % mod; + } + } + + for (int i = 1; i <= n; i++) { + ans = (static_cast(ans) + f[a[i]][b[i]]) % mod; + } + + for (int i = 1; i <= n; i++) { + ans = ((static_cast(ans) - C(2 * a[i] + 2 * b[i], 2 * a[i])) % mod + mod) % mod; + } + + cout << (static_cast(ans) * inv[2] % mod) << endl; + + return 0; +} diff --git a/AtCoder/AGC001/E/data/01-01.in b/AtCoder/AGC001/E/data/01-01.in new file mode 100644 index 00000000..ae5e2e5f --- /dev/null +++ b/AtCoder/AGC001/E/data/01-01.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b8f6ec9dfef5b1a84c39f441635acde52797ab71ed748e6537022a971fcc2a3 +size 20 diff --git a/AtCoder/AGC001/E/data/01-01.out b/AtCoder/AGC001/E/data/01-01.out new file mode 100644 index 00000000..4cbe1c26 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-01.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:113aa41ad08c300b199ca07322293f9fd0c07c29ad76fdb844a16473f075af5e +size 10 diff --git a/AtCoder/AGC001/E/data/01-02.in b/AtCoder/AGC001/E/data/01-02.in new file mode 100644 index 00000000..fecb1580 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-02.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:153fd14ed14a48a5f92b43d39328beaedb4c6b50c3ed29f3db45b8f5f0a54335 +size 8885 diff --git a/AtCoder/AGC001/E/data/01-02.out b/AtCoder/AGC001/E/data/01-02.out new file mode 100644 index 00000000..01e58a21 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-02.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4733a684a2ccc1103a814b450574725135b08bca025a7653b48d6aa04edbcc31 +size 10 diff --git a/AtCoder/AGC001/E/data/01-03.in b/AtCoder/AGC001/E/data/01-03.in new file mode 100644 index 00000000..5a7edd0a --- /dev/null +++ b/AtCoder/AGC001/E/data/01-03.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:add87d0687ff31d32c8729440b6df62b3e05600c4c9ec4ca17a6cdb93c8077ff +size 889077 diff --git a/AtCoder/AGC001/E/data/01-03.out b/AtCoder/AGC001/E/data/01-03.out new file mode 100644 index 00000000..fcea1e94 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-03.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:387f93648470f71ec782bb38abc2c91deca68528d7184e7622cbaeeffdf828d5 +size 10 diff --git a/AtCoder/AGC001/E/data/01-04.in b/AtCoder/AGC001/E/data/01-04.in new file mode 100644 index 00000000..2f4625dc --- /dev/null +++ b/AtCoder/AGC001/E/data/01-04.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab00d24e73b9487f41bf456a7e42d24e5e52aad22e0c281c54d42efb232be2dc +size 1779199 diff --git a/AtCoder/AGC001/E/data/01-04.out b/AtCoder/AGC001/E/data/01-04.out new file mode 100644 index 00000000..15a59c93 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-04.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f111efd35fec4640e951b13022379643ed7a8aa838a931dadb6fd701a3fd8f84 +size 10 diff --git a/AtCoder/AGC001/E/data/01-05.in b/AtCoder/AGC001/E/data/01-05.in new file mode 100644 index 00000000..d4118c8c --- /dev/null +++ b/AtCoder/AGC001/E/data/01-05.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05aa004d5ae6c6d0c3b73142c2a7a8e0e0004b4715a189c26a165c5ba99982bc +size 1778690 diff --git a/AtCoder/AGC001/E/data/01-05.out b/AtCoder/AGC001/E/data/01-05.out new file mode 100644 index 00000000..c57b7cf5 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-05.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:74316e97b7ebd2863b54220e769d4a00b3071084c169943823505d5a4ff7b1ec +size 10 diff --git a/AtCoder/AGC001/E/data/01-06.in b/AtCoder/AGC001/E/data/01-06.in new file mode 100644 index 00000000..dfa145a3 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-06.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10a1a6d702aaa07ffdb9a06e320c9f46a4c7323ce194120e45095f8f4d0ea692 +size 2000007 diff --git a/AtCoder/AGC001/E/data/01-06.out b/AtCoder/AGC001/E/data/01-06.out new file mode 100644 index 00000000..f7478a32 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-06.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db6650680c8ca0dd4dece19fafb970254a674c5dc029b058044d2977f20b194f +size 10 diff --git a/AtCoder/AGC001/E/data/01-07.in b/AtCoder/AGC001/E/data/01-07.in new file mode 100644 index 00000000..35b6da77 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-07.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b798c272c436df7b3c193022adba404c4cdbafc09471672f636182a35392d36 +size 10 diff --git a/AtCoder/AGC001/E/data/01-07.out b/AtCoder/AGC001/E/data/01-07.out new file mode 100644 index 00000000..cb90f684 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-07.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06e9d52c1720fca412803e3b07c4b228ff113e303f4c7ab94665319d832bbfb7 +size 2 diff --git a/AtCoder/AGC001/E/data/01-08.in b/AtCoder/AGC001/E/data/01-08.in new file mode 100644 index 00000000..2c2c8bd3 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-08.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9b09c4af8da062bc6decebe1acf4a1de5492b49cfc7de01fe689beb0a2cffe3 +size 800007 diff --git a/AtCoder/AGC001/E/data/01-08.out b/AtCoder/AGC001/E/data/01-08.out new file mode 100644 index 00000000..2ee5a4dc --- /dev/null +++ b/AtCoder/AGC001/E/data/01-08.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfbddc0402a7baa5cd355c2df2a8ae9291ae8dfd15922708e2f809d0d03e1fda +size 10 diff --git a/AtCoder/AGC001/E/data/01-09.in b/AtCoder/AGC001/E/data/01-09.in new file mode 100644 index 00000000..2738342a --- /dev/null +++ b/AtCoder/AGC001/E/data/01-09.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d6a2e49288ccb616e8c176d20529aaf448efbf195becb8ef23fd2045e6f6d00c +size 2000007 diff --git a/AtCoder/AGC001/E/data/01-09.out b/AtCoder/AGC001/E/data/01-09.out new file mode 100644 index 00000000..09c1fe43 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-09.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bd62ff7ada9bb5c19bbac7c4d941e949ecad5064d93b4da79600dcc68e1e617 +size 10 diff --git a/AtCoder/AGC001/E/data/01-10.in b/AtCoder/AGC001/E/data/01-10.in new file mode 100644 index 00000000..4d26c3c3 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5456319be6e2607ff87fc6c0983dded1ce4e08b48cb6df2440b3103dccfa71ab +size 1938747 diff --git a/AtCoder/AGC001/E/data/01-10.out b/AtCoder/AGC001/E/data/01-10.out new file mode 100644 index 00000000..c080bd5a --- /dev/null +++ b/AtCoder/AGC001/E/data/01-10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68d30741076a3da33635fc84154643161d7c0fe37bd1b4226d8088040661ebc3 +size 10 diff --git a/AtCoder/AGC001/E/data/01-11.in b/AtCoder/AGC001/E/data/01-11.in new file mode 100644 index 00000000..e8fc2ff3 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d654bc7eb9ecd1453a57c339fc040c305574b386a41a20858607e1a728ae9e46 +size 2000007 diff --git a/AtCoder/AGC001/E/data/01-11.out b/AtCoder/AGC001/E/data/01-11.out new file mode 100644 index 00000000..315cb274 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cbf4e2377b13c53827dc6fc3da74fad567a161469d4adbcfdf6c35e3d4bbc408 +size 10 diff --git a/AtCoder/AGC001/E/data/01-12.in b/AtCoder/AGC001/E/data/01-12.in new file mode 100644 index 00000000..4037313e --- /dev/null +++ b/AtCoder/AGC001/E/data/01-12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24c2576e4e4e8166fd1118da7069b00be3e08ea0fda3fdcc3899ac9d02a4af40 +size 2000007 diff --git a/AtCoder/AGC001/E/data/01-12.out b/AtCoder/AGC001/E/data/01-12.out new file mode 100644 index 00000000..1d3e6a6c --- /dev/null +++ b/AtCoder/AGC001/E/data/01-12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1819025c8919c1d5fc75b4a9cc1d9770da11d09a14aab861304533b5b7bba24 +size 10 diff --git a/AtCoder/AGC001/E/data/01-13.in b/AtCoder/AGC001/E/data/01-13.in new file mode 100644 index 00000000..80cd938f --- /dev/null +++ b/AtCoder/AGC001/E/data/01-13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:44f2cdc8012c470a4738551be0c613f2e03f67832cdc6fc4a9bb6c9d003c844f +size 1778198 diff --git a/AtCoder/AGC001/E/data/01-13.out b/AtCoder/AGC001/E/data/01-13.out new file mode 100644 index 00000000..a0734a8b --- /dev/null +++ b/AtCoder/AGC001/E/data/01-13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36f5124249fc84152c96effb4a68b48533aeb6fffc6a5b8881783a3d82be3c45 +size 10 diff --git a/AtCoder/AGC001/E/data/01-14.in b/AtCoder/AGC001/E/data/01-14.in new file mode 100644 index 00000000..37a17b8b --- /dev/null +++ b/AtCoder/AGC001/E/data/01-14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38e1a411c581987c5a0cea640ff6c7871e83311ec1d88e2cd73b1921b1269111 +size 1779014 diff --git a/AtCoder/AGC001/E/data/01-14.out b/AtCoder/AGC001/E/data/01-14.out new file mode 100644 index 00000000..07b2dd83 --- /dev/null +++ b/AtCoder/AGC001/E/data/01-14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a09afe0356f42a1ce54df558fd27ea5078d3c59cc0620157c4b8dec194055b0 +size 10 diff --git a/AtCoder/AGC001/E/data/sample-01.in b/AtCoder/AGC001/E/data/sample-01.in new file mode 100644 index 00000000..a86c0660 --- /dev/null +++ b/AtCoder/AGC001/E/data/sample-01.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a42fcae56c7b7e04e63bb7cdd46f2161d2f6f8e5d53771430d504766f4883cbb +size 14 diff --git a/AtCoder/AGC001/E/data/sample-01.out b/AtCoder/AGC001/E/data/sample-01.out new file mode 100644 index 00000000..2e1db300 --- /dev/null +++ b/AtCoder/AGC001/E/data/sample-01.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20d2add851bf39edcc6b5e830930f962db7e19dffa2cab8610eed551eda6c302 +size 3