結果
問題 |
No.1596 Distance Sum in 2D Plane
|
ユーザー |
|
提出日時 | 2021-07-09 22:03:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,035 bytes |
コンパイル時間 | 4,589 ms |
コンパイル使用メモリ | 238,172 KB |
実行使用メモリ | 814,592 KB |
最終ジャッジ日時 | 2024-07-01 16:27:26 |
合計ジャッジ時間 | 8,021 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | MLE * 1 -- * 16 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #define ll long long int #define INF 1000000000000000000 #define pll pair<ll,ll> using namespace atcoder; using namespace std; using mint = modint1000000007; ostream &operator<<(std::ostream &os, mint p){ os << p.val(); return os; } int main(void){ ll n, m; cin >> n >> m; set<pll> rs, cs; n++; for (ll i = 0; i < m; i++){ ll t, x, y; cin >> t >> x >> y; if (t == 1) rs.insert(pll(x, y)); else cs.insert(pll(x, y)); } vector<vector<mint>> dp(n, vector<mint>(n, 0)); vector<vector<mint>> dp2(n, vector<mint>(n, 0)); dp[0][0] = 1; dp2[0][0] = 0; for (ll i = 0; i < n; i++){ for (ll j = 0; j < n; j++){ if (i != n-1){ dp[i+1][j] += dp[i][j]; dp2[i+1][j] += dp2[i][j] + (rs.count(pll(i, j)) ? 0 : dp[i][j]); } if (j != n-1){ dp[i][j+1] += dp[i][j]; dp2[i][j+1] += dp2[i][j] + (cs.count(pll(i, j)) ? 0 : dp[i][j]); } } } cout << dp2[n-1][n-1] << endl; return 0; }