結果

問題 No.801 エレベーター
ユーザー AquariusAquarius
提出日時 2019-03-20 14:24:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 167,656 KB
実行使用メモリ 74,028 KB
最終ジャッジ日時 2023-10-19 04:12:24
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,724 KB
testcase_01 AC 2 ms
5,736 KB
testcase_02 AC 2 ms
5,756 KB
testcase_03 AC 7 ms
8,636 KB
testcase_04 AC 6 ms
8,616 KB
testcase_05 AC 7 ms
8,612 KB
testcase_06 AC 7 ms
8,656 KB
testcase_07 AC 7 ms
8,672 KB
testcase_08 AC 7 ms
8,696 KB
testcase_09 AC 7 ms
8,640 KB
testcase_10 AC 7 ms
8,648 KB
testcase_11 AC 7 ms
8,620 KB
testcase_12 AC 7 ms
8,672 KB
testcase_13 AC 174 ms
74,012 KB
testcase_14 AC 175 ms
74,028 KB
testcase_15 AC 173 ms
73,928 KB
testcase_16 AC 174 ms
73,940 KB
testcase_17 AC 174 ms
73,964 KB
testcase_18 AC 174 ms
73,964 KB
testcase_19 AC 174 ms
74,000 KB
testcase_20 AC 174 ms
73,976 KB
testcase_21 AC 175 ms
74,000 KB
testcase_22 AC 175 ms
74,028 KB
testcase_23 AC 173 ms
73,964 KB
testcase_24 AC 173 ms
73,964 KB
testcase_25 AC 173 ms
73,964 KB
testcase_26 AC 175 ms
73,976 KB
testcase_27 AC 173 ms
73,928 KB
testcase_28 AC 179 ms
74,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using PP = pair<long, long>;
const int INF = 1e9;
template <class T> T Next() { T t; cin >> t; return t; }

const int mod = 1000000007;
int n, m, k;
int dp[3001][3001];
int dq[3000][3001];

int l[3000];
int r[3000];
int main() {
  cin >> n >> m >> k;
  for (int j = 0; j < m; ++j) {
    cin >> l[j] >> r[j];
    --l[j];
  }
  
  dp[0][0] = 1; 
  for (int q = 0; q < k; ++q) {
    for (int i = 0; i < n; ++i) {
      dq[q][i + 1] = (dq[q][i] + dp[q][i]) % mod;
    }
    
    for (int j = 0; j < m; ++j) {
      int add = (dq[q][r[j]] + mod - dq[q][l[j]]) % mod;
      dp[q + 1][l[j]] = (dp[q + 1][l[j]] + add) % mod;
      dp[q + 1][r[j]] = (dp[q + 1][r[j]] + mod - add) % mod;
    }
    
    for (int i = 0; i < n; ++i) {
      dp[q + 1][i + 1] = (dp[q + 1][i + 1] + dp[q + 1][i]) % mod; 
    }
  }
  
  cout << dp[k][n - 1] << endl;
}
0