結果

問題 No.801 エレベーター
ユーザー AquariusAquarius
提出日時 2019-03-20 14:31:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 170,028 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:14:08
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 123 ms
4,348 KB
testcase_14 AC 123 ms
4,348 KB
testcase_15 AC 123 ms
4,348 KB
testcase_16 AC 124 ms
4,348 KB
testcase_17 AC 124 ms
4,348 KB
testcase_18 AC 123 ms
4,348 KB
testcase_19 AC 123 ms
4,348 KB
testcase_20 AC 123 ms
4,348 KB
testcase_21 AC 124 ms
4,348 KB
testcase_22 AC 123 ms
4,348 KB
testcase_23 AC 123 ms
4,348 KB
testcase_24 AC 123 ms
4,348 KB
testcase_25 AC 123 ms
4,348 KB
testcase_26 AC 123 ms
4,348 KB
testcase_27 AC 124 ms
4,348 KB
testcase_28 AC 132 ms
4,348 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 l[3000];
int r[3000];

vector<int> sub(const vector<int>& curr) {
  vector<int> tmp(n + 1);
  for (int i = 0; i < n; ++i) {
    tmp[i + 1] = (tmp[i] + curr[i]) % mod;
  }
  
  vector<int> next(n + 1);  
  for (int j = 0; j < m; ++j) {
    int add = (tmp[r[j]] + mod - tmp[l[j]]) % mod;
    next[l[j]] = (next[l[j]] + add) % mod;
    next[r[j]] = (next[r[j]] + mod - add) % mod;
  }

  for (int i = 0; i < n; ++i) {
    next[i + 1] = (next[i + 1] + next[i]) % mod; 
  }
  return next;
}

int main() {
  cin >> n >> m >> k;
  for (int j = 0; j < m; ++j) {
    cin >> l[j] >> r[j];
    --l[j];
  }
  
  vector<int> curr(n + 1);
  curr[0] = 1;
  
  for (int z = 0; z < k; ++z) {
    curr = sub(curr);
  }
  
  cout << curr[n - 1] << endl;
}
0