結果

問題 No.1596 Distance Sum in 2D Plane
ユーザー h2929h2929
提出日時 2021-07-09 22:03:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,035 bytes
コンパイル時間 4,144 ms
コンパイル使用メモリ 236,088 KB
実行使用メモリ 814,696 KB
最終ジャッジ日時 2023-09-14 09:06:47
合計ジャッジ時間 7,589 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0