結果

問題 No.801 エレベーター
ユーザー AquariusAquarius
提出日時 2019-03-20 14:44:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 171,168 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:22:29
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 2 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 2 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 66 ms
4,348 KB
testcase_14 AC 67 ms
4,348 KB
testcase_15 AC 65 ms
4,348 KB
testcase_16 AC 66 ms
4,348 KB
testcase_17 AC 66 ms
4,348 KB
testcase_18 AC 65 ms
4,348 KB
testcase_19 AC 66 ms
4,348 KB
testcase_20 AC 66 ms
4,348 KB
testcase_21 AC 66 ms
4,348 KB
testcase_22 AC 65 ms
4,348 KB
testcase_23 AC 65 ms
4,348 KB
testcase_24 AC 65 ms
4,348 KB
testcase_25 AC 65 ms
4,348 KB
testcase_26 AC 65 ms
4,348 KB
testcase_27 AC 65 ms
4,348 KB
testcase_28 AC 69 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> cur;
vector<int> nxt;
vector<int> tmp;

void addmod(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}

int plusmod(int a, int b) {
  int ret = a + b;
  return ret >= mod ? ret - mod : ret;
}

void sub() {
  for (int i = 0; i < n; ++i) {
    tmp[i + 1] = plusmod(tmp[i], cur[i]);
  }
  
  nxt.assign(n + 1, 0);
  for (int j = 0; j < m; ++j) {
    int s = plusmod(tmp[r[j]], mod - tmp[l[j]]);
    addmod(nxt[l[j]], s);
    addmod(nxt[r[j]], mod - s);
  }

  for (int i = 0; i < n; ++i) {
    addmod(nxt[i + 1], nxt[i]); 
  }
}

int main() {
  cin >> n >> m >> k;
  for (int j = 0; j < m; ++j) {
    cin >> l[j] >> r[j];
    --l[j];
  }
  
  cur.resize(n + 1);
  nxt.resize(n + 1);
  tmp.resize(n + 1);
  
  cur[0] = 1;
  for (int z = 0; z < k; ++z) {
    sub();
    swap(cur, nxt);
  }
  
  cout << cur[n - 1] << endl;
}
0