結果
問題 | No.1596 Distance Sum in 2D Plane |
ユーザー | 👑 Nachia |
提出日時 | 2021-07-09 21:37:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,059 bytes |
コンパイル時間 | 3,035 ms |
コンパイル使用メモリ | 153,072 KB |
実行使用メモリ | 7,908 KB |
最終ジャッジ日時 | 2023-09-14 08:04:21 |
合計ジャッジ時間 | 5,755 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 14 ms
7,908 KB |
testcase_01 | AC | 14 ms
7,816 KB |
testcase_02 | AC | 71 ms
7,744 KB |
testcase_03 | AC | 70 ms
7,888 KB |
testcase_04 | AC | 70 ms
7,740 KB |
testcase_05 | AC | 71 ms
7,904 KB |
testcase_06 | AC | 69 ms
7,824 KB |
testcase_07 | AC | 69 ms
7,772 KB |
testcase_08 | AC | 73 ms
7,824 KB |
testcase_09 | AC | 69 ms
7,736 KB |
testcase_10 | AC | 68 ms
7,736 KB |
testcase_11 | AC | 58 ms
7,772 KB |
testcase_12 | AC | 57 ms
7,776 KB |
testcase_13 | AC | 57 ms
7,824 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | RE | - |
testcase_19 | AC | 2 ms
4,376 KB |
ソースコード
#include <atcoder/all> #include <iostream> #include <vector> #include <algorithm> #include <set> using namespace atcoder; using namespace std; using ll = long long; using ull = unsigned long long; const ull MOD = 1000000007; using mll = static_modint<1000000007>; #define rep(i,n) for(int i=0; i<(n); i++) vector<mll> F,I,iF; void initComb(int Z){ F.assign(Z,1); for(int i=1; i<=Z; i++) F[i] = F[i-1] * i; I.assign(Z,1); for(int i=2; i<=Z; i++) I[i] = -(I[MOD%i] * (MOD / i)); iF.assign(Z,1); for(int i=1; i<=Z; i++) iF[i] = iF[i-1] * I[i]; } mll Comb(int n,int r){ return F[n] * iF[r] * iF[n-r]; } int main(){ int N,M; cin >> N >> M; initComb(N+N); mll ans = Comb(N+N,N) * N * 2; rep(i,M){ int t,x,y; cin >> t >> x >> y; mll d = 1; d *= Comb(x+y,x); if(t == 1) d *= Comb(N-x-1+N-y,N-y); if(t == 2) d *= Comb(N-x+N-y-1,N-x); ans -= d; } cout << ans.val() << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;