結果

問題 No.801 エレベーター
コンテスト
ユーザー Aquarius
提出日時 2019-03-20 14:31:01
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 935 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,537 ms
コンパイル使用メモリ 182,768 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-04-07 03:15:25
合計ジャッジ時間 9,411 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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